Listbox Pre Change

I have a listbox that shows an edit box on a desktop window. I then have a button to save the changes which works fine. I have a property called “isSaved” which is set to false when the row in the listbox is changed but I also want to be able to check if “isSaved” is true and if not then put up a warning that the edit box has not been saved. The problem I have is I can’t see a way to stop the listbox from changing the row in the “change” event. Can anyone suggest a way that I can stop the listbox change event from changing until I tell it that it can change?

Hi Nathan,

When you select a Row, move to top or to bottom, the Change event is fired even if for us, the Listbox contents does not change. Then it is not possible to use the Change event as is.

Did I rephrase correctly your actual problem ?

I use a trick in Answers for the sidebar where it keeps track of the last row you were on, and if you select something invalid or try to go past the last row, I just change the selected row back the the last known acceptable one. You may want to do something similar. Changing the listbox selection needs to be done in a timer though if you’re trying to change the selection in the Change event.

Xojo.core.timer.CallLater might actually be sufficient, it didn’t exist when I implemented my selection fixer.