使用ListboxName.Items.Add(item As Object)语句添加项,示例如下:
1、如下图有一textbox 、listbox及一命令按钮;
2、定义按钮单击事件为:
Private Sub Command6_Click()
listbox1.Items.Add (textbox1.Text)
End Sub
用ListboxName.Items.Add(item As Object)语句添加项
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
ListBox1.Items.Add("北京市")
End Sub
Private Sub province_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
province.SelectedIndexChanged
If province.Text = "北京市" Then
txtCapital.Text = "北京"
End If
end sub
ListBox1.Items.Add(TextBox1.Text)
你要怎么添加?textbox里换行的话 listbox也要换行吗?,还是将textbox里的所有文本直接添加到listbox的第一行呢?