Memindahkan isi Listbox

alfa6661
- December 16, 2011
0 (0 votes)
Rate :
Artikel ini merupakan potongan kode untuk memindahkan isi listbox pertama ke listbox kedua

Artikel ini berisi potongan kode program untuk memindahkan isi dari listbox pertama ke listbox ke dua.

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListBox1.Items.Add("Aceh")
        ListBox1.Items.Add("Jakarta")
        ListBox1.Items.Add("Bandung")
        ListBox1.Items.Add("Bali")
End Sub
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error Resume Next
        ListBox2.Items.Add(ListBox1.SelectedItem)
        ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
 
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        On Error Resume Next
        ListBox1.Items.Add(ListBox2.SelectedItem)
        ListBox2.Items.Remove(ListBox2.SelectedItem)
End Sub
 
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListBox2.Items.AddRange(ListBox1.Items)
        ListBox1.Items.Clear()
End Sub
 
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ListBox1.Items.AddRange(ListBox2.Items)
        ListBox2.Items.Clear()
End Sub

Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter

– Eric S. Raymond

Have a better explanation?

If you have comments about this post. Please write your comments below

No comments associated with this article