0
我从文本框知道列表框中,你可以使用类似:如何将列表框中的项目添加到另一个列表框?
listBox1.Items.Add(textBox1.Text)
但是,如何将两个ListBox之间的这项工作?谢谢。
我从文本框知道列表框中,你可以使用类似:如何将列表框中的项目添加到另一个列表框?
listBox1.Items.Add(textBox1.Text)
但是,如何将两个ListBox之间的这项工作?谢谢。
假设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