# Problem manually reordering a listbox

**URL:** <https://forum.xojo.com/t/problem-manually-reordering-a-listbox/81526>\
**Category:** macOS\
**Created:** [August 26, 2024, 3:20pm UTC](https://forum.xojo.com/t/problem-manually-reordering-a-listbox/81526 "2024-08-26T15:20:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Allen](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e19adc/32.png) [@John\_Allen](https://forum.xojo.com/u/John_Allen)\
**Post date:** [August 26, 2024, 3:20pm UTC](https://forum.xojo.com/t/problem-manually-reordering-a-listbox/81526/1 "2024-08-26T15:20:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [August 26, 2024, 3:24pm UTC](https://forum.xojo.com/t/problem-manually-reordering-a-listbox/81526/2 "2024-08-26T15:24:41Z")

</div>

Create a sample project, zip it and upload to the forum. That way it will be easier for someone to give you ideas.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [August 26, 2024, 4:02pm UTC](https://forum.xojo.com/t/problem-manually-reordering-a-listbox/81526/3 "2024-08-26T16:02:03Z")

</div>

If you’re attempting to save the order in the [DragReorderRows](https://documentation.xojo.com/api/user_interface/desktop/desktoplistbox.html#desktoplistbox-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.

---

<div class="post-metadata">

**Author:** ![John\_Allen](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e19adc/32.png) [@John\_Allen](https://forum.xojo.com/u/John_Allen)\
**Post date:** [August 26, 2024, 9:01pm UTC](https://forum.xojo.com/t/problem-manually-reordering-a-listbox/81526/4 "2024-08-26T21:01:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![John\_Allen](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e19adc/32.png) [@John\_Allen](https://forum.xojo.com/u/John_Allen)\
**Post date:** [August 27, 2024, 8:40am UTC](https://forum.xojo.com/t/problem-manually-reordering-a-listbox/81526/5 "2024-08-27T08:40:30Z")

</div>

Thanks for all your advice, the Timer approach worked.
