I know what I want but don't know how

  • Thread starter Thread starter Jim Campau
  • Start date Start date
J

Jim Campau

What I am looking for is as follows:

I am sure you have seen where there are 2 list boxes side by side with
arrows pointing each way inbetween them. Then when you select something on
the left pane and click the right arrow in the middle, what you selected
moves over to the right pane and vice versa.

How is this done?
Is this "Split" on the tool box?

Can some one point me to a tutorial or send / explain the code?

Thank you in advance.
 
Jim,

If listbox1 has an item selected, then add the selected item in listbox1 to
listbox2 and remove the selected item from listbox1:

If ListBox1.SelectedIndex >= 0 Then
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)
End If

Kerry Moorman
 
Jim Campau said:
What I am looking for is as follows:

I am sure you have seen where there are 2 list boxes side by side with
arrows pointing each way inbetween them. Then when you select something on
the left pane and click the right arrow in the middle, what you selected
moves over to the right pane and vice versa.

How is this done?
Is this "Split" on the tool box?

Can some one point me to a tutorial or send / explain the code?



It will probably be something like this:


Private Sub MoveItem(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

' Insert at destination's current selection point
If ListBox2.SelectedItem IsNot Nothing Then
ListBox2.Items.Insert(ListBox2.SelectedIndex, ListBox1.SelectedItem)
Else
ListBox2.Items.Add(ListBox1.SelectedItem)
End If

' Remove from source list
ListBox1.Items.Remove(ListBox1.SelectedItem)

End Sub


LFS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top