Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub New()
- InitializeComponent()
- ListBox1.Items.Add("An item")
- ListBox1.Items.Add("Another item")
- ListBox1.Items.Add("This is an item too")
- ListBox1.Items.Add("This item is initially selected")
- ListBox1.Items.Add("Yet another item")
- ListBox1.Sorted = True
- ListBox2.Sorted = True
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- MoveItem(ListBox1, ListBox2)
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- MoveItem(ListBox2, ListBox1)
- End Sub
- Private Sub MoveItem(fromBox As ListBox, toBox As ListBox)
- If fromBox.SelectedIndex > ListBox.NoMatches Then
- Dim moveText As String = fromBox.Items(fromBox.SelectedIndex)
- fromBox.Items.RemoveAt(fromBox.SelectedIndex)
- toBox.Items.Add(moveText)
- toBox.SelectedIndex = toBox.Items.IndexOf(moveText)
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement