Given a form (frmMain) which contains a listbox "lbSelected" (multi-select) and 2 control buttons "btnMoveUp" & "btnMoveDown" that should allow the user to move the selected items (from the listbox) up or down using the buttons. Thing is I have no clue how to change the index of a selected item in a listbox, forget trying to handle multi-select - so I was hoping maybe someone could give me some help/hints.
So far I got to this point:
So this will give me the index of each of the selected items...
Consequently it could also be good to do it this way I imagine:
Where I am getting the list of selected items instead and somehow modifiying their index?
Now I need to find a way to either +1 or -1 each of the corresponding items indexes (depending on if I am going UP or DOWN) and always be careful that I am not already at the top or bottom...
Any help would be greatly appreciated.
Thanks,
So far I got to this point:
Code:
// Get the current index of all selected items in the listbox
ListBox.SelectedIndexCollection indxcolSelected = lbSelected.SelectedIndices;
Consequently it could also be good to do it this way I imagine:
Code:
ListBox.SelectedObjectCollection objcolSelected = lbSelected.SelectedItems;
Now I need to find a way to either +1 or -1 each of the corresponding items indexes (depending on if I am going UP or DOWN) and always be careful that I am not already at the top or bottom...
Any help would be greatly appreciated.
Thanks,