I have a listbox that I allow the user to manually drag reorder. The order should then be saved and reinstated next time the app runs.
The problem I’m finding is that the Save is not enabling. The debugger is telling me the internal buffer (self - contents - listbox1 - contents) has not been updated. If I allow the app to continue then the display updates, if I go into the debugger again then the buffer has been updated.
I’ve tried, listbox1.refresh, cell refresh, self.refresh but nothing works.
I’m saving the starting list order and after a change comparing the original and the new version and it’s saying there is no change. A second change is detected, but that seems to be the first one.
Anyone got any ideas?
Create a sample project, zip it and upload to the forum. That way it will be easier for someone to give you ideas.
If you’re attempting to save the order in the DragReorderRows event, remember that the order has not changed when the event is raised. This happens because row reordering when ExpandableRows is true is a little bit more complicated.
If you need a quick solution to work around that for a non-expandable-row Listbox you can relay the save-order function through a 0ms Timer. The timer will fire as quickly as possible, but will occur after the framework has re-ordered the Listbox for you.
As usual, a basic program works fine.
The listbox does not have expandable rows.
The DragReorder event is used to check what the user has asked for. The contents of row0 are fixed and cannot be moved and another row cannot go above it. The listbox being reordered identities the number and order of columns on another window and the top row is the key to that other window. So the DragReorder event does have some work to do.
The event itself doesn’t enable Save, it calls a method to check for changes. From what Tim is saying, event calling another method the window will not have been refreshed. I will try the timer approach.
Thanks for all your advice, the Timer approach worked.