DELPHI - Moving Listbox Items?
A few weeks back, i started making a project on my own, easily discovered how to move a list item up and down the list:
Code:
lstMain.Items.Move(lstMain.ItemIndex,lstMain.ItemIndex -1);
My question comes here, which i feel ridicolous for asking :blush:
1) When you move the item, how do you keep it selected? If i press a up button for example, i always have to click the item, then the button, when really i should'nt
2) How do you stop the first, and last item in the list from been moved?
CHEERS :)
Re: DELPHI - Moving Listbox Items?
Re: DELPHI - Moving Listbox Items?
I am not sure what you mean. :confused:
Re: DELPHI - Moving Listbox Items?
Imagine, a listbox, a command button for up, and one for down. There are the following items in the list:
1
2
3
4
5
6
7
8
9
If i highlight 9 (the blue bar highlights the 9) and press the up button, the 9 will swap places with 8 right. Thats hunky dorky, but when i press that button, the listbox loses focus of the 9, meaning the blue bar is no longer over the 9 (so the user would have to re-click the item again)
Is that better? :cry:
Re: DELPHI - Moving Listbox Items?
You would do as you would do in VB:
Re: DELPHI - Moving Listbox Items?
If that works, then i must be such a idiot :blush: :lol:
EDIT: I sent you a PM :thumb:
Re: DELPHI - Moving Listbox Items?
Why don't you use a special key to move items up and down. In some list boxes, you can move items by holding down the control key and pressing the up and down arrows. :)
P.s: Merry Christmas