I am using a listboxe to show a summary of a subset of a large inventory.  There are also other buttons that allow you to filter which items you see.  There is a notes field for the inventory that gets modified a lot to track the status of items. I had it that you could update an item by double-clicking it, and it would bring up a modal dialog to modify the entry, but people in the lab were requesting the ability to edit the notes directly in the listbox.  I was able to implement that, and the edit is started with a double-click.

However, there is a strange glitch.  If the user is in the middle of editting a note in the listbox, and then changes the filter, the contents of the listbox change as it populates with the new list of items, except for the cell being editted.  When the user ends the edit (by clicking somewhere else, or hitting enter), then the "End edit" event code (7) gets issued, and then my code updates the new item in that spot on the list, instead of the one the user selected in the first place.

Does anyone have a suggestion how to deal with this?  Is there a way to force an end to a listbox edit before the list repopulates?  I couldn't figure out how to do it with setEditCell. I would be grateful for suggestions.


As a matter of fact, I can't find any way to do that. Seems like an oversight. ListBox setEditCell can *start* editing, but won't end editing. And I can't find a way to learn if a cell is being edited, either.

This all seems like an oversight on our part.

Maybe as a workaround you could disable filtering on a start edit event and re-enable on stop edit?

The solution I'm thinking of now is to store the record ID in userData on a beginEdit event, and use that when an endEdit event occurs.  I fear that could go awry under conditions I haven't imagined yet.

Conceivably, you could destroy the listbox and create a brand  new one. We have code to make sure that the edit box that does the actual editing lives long enough to not cause crashes. But if it does crash, you know what to do :)

I forgot all about the start/end edit events. That will also give you the row/column of a cell being edited so that you can tell which one is affected. If you store some info in userData in the listbox, you can at least code defensively even if you can't cancel the edit.

Good call Tony! Do you need a job? :)