Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reordering Items in a listbox

Status
Not open for further replies.

NatGreen

Programmer
Apr 19, 2002
90
0
0
US
How do I reorder the items in a list box?

I have an Up arrow button and a down arrow button next to my listbox on the form. When I highlight a Item in the listbox and click on the up arrow button, I wan it to move my selection up in order.

Thanks for your help!
 
Do you have knwoledge on ListBox.SelectedItem & ListBox.SelectedIndex?

The concept is, create a dummy variable. Once your user selected an item in the list and press the up or down button, the program store the selected item into the dummy variable, like this

tmpDummy = ListBox.SelectedItem

Then, you want to get the selected item's index by using ListBox.SelectedIndex, as well as it pervious/next item's index.

Now, you copy the next/pervious item into your current selected item position. And copy the dummy variable into the next/pervious position. And you get it done.

It's pretty easy. Unlucky I'm a bit busy now or I will send you a code... hope you get the idea.

 
How do I get the previous and Next Items Index?

Thanks again,
NatGreen
 
andylo,

Can you send me the code when you get a chance?

Thanks!

Regards,
NatGreen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top