Hello, I am looking for help with writing a listbox control that will initially be populated with a handful of servernames. The servernames do not show up in any particular order, done on purpose, because I want to be able to rearrange the items in the list box by simply dragging them within the list box to reorder them.
Any help would be appreciated!
Tim
Reorder list box by drag and drop
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Reorder list box by drag and drop
Here is a short tutorial on how to use drag/drop with listboxes:
https://www.codeproject.com/Articles/20 ... r-s-Tutori
https://www.codeproject.com/Articles/20 ... r-s-Tutori
Re: Reorder list box by drag and drop
I should also note that there is no way to use drag/drop to reorder items in a single ListBox. You would have to write custom code to select and move an item in the list order.
You can use the "MouseDown" event to select the item but getting the target will require some difficult coding that can display an insertion point while hovering. This will likely require adding some C# code helpers to the form.
You can use the "MouseDown" event to select the item but getting the target will require some difficult coding that can display an insertion point while hovering. This will likely require adding some C# code helpers to the form.
- timstspry17
- Posts: 45
- Last visit: Tue Apr 18, 2023 2:49 pm
Re: Reorder list box by drag and drop
Thanks for the information. Looks a bit more involved than I had hoped. Will probably use 2 list boxes as I have seen examples of. Doing it in a single list box would have been nice, but 2 list boxes will work too.
Tim
Tim