使用ListboxName.Items.Add(item As Object)语句添加项,示例如下:
1、如下图有一textbox 、listbox及一命令按钮;
2、定义按钮单击事件为:
Private Sub Command6_Click()
listbox1.Items.Add (textbox1.Text)
End Sub
使用FolderBrowserDialog控件If FolderBrowserDialog1.ShowDialog() <>DialogResult.Cancel Then
TextBox6.Text = FolderBrowserDialog1.SelectedPath
TextBox6.SelectionStart = TextBox6.Text.Length
Dim FileNames() As String = Directory.GetFiles(TextBox6.Text)
For i As Integer = 0 To FileNames.Length - 1
ListBox1.Items.Add(Path.GetFileName(FileNames(i)))
Next
End If
在窗体中拉两个listbox控件和一个Button控件,然后双击Button控件将如下代码复制到光标位置;Dim a As String
a = ListBox1.SelectedItem
ListBox2.Items.Add(a)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)