2015-10-21 134 views

回答

0

假設SelectionMode設置爲One,並且要複製所選項目:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    If ListBox1.SelectedIndex <> -1 Then 
     ListBox2.Items.Add(ListBox1.SelectedItem) 
    End If 
End Sub 

如果你想移動選擇的項目,則:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    If ListBox1.SelectedIndex <> -1 Then 
     ListBox2.Items.Add(ListBox1.SelectedItem) 
     ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) 
    End If 
End Sub 
相關問題