2 x ListBox 既 Item 互換
Form1.vb |
Public Class Form7 Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Button1.Text = ">>" Button2.Text = "<<" ListBox1.Items.Add("Team ID") ListBox1.Items.Add("Team Name") ListBox1.Items.Add("League ID") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If ListBox1.SelectedIndex > -1 And ListBox1.Items.Count > 0 Then ListBox2.Items.Add(ListBox1.SelectedItem) ListBox1.Items.Remove(ListBox1.SelectedItem) End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If ListBox2.SelectedIndex > -1 And ListBox2.Items.Count > 0 Then ListBox1.Items.Add(ListBox2.SelectedItem) ListBox2.Items.Remove(ListBox2.SelectedItem) End If End Sub End Class |