在窗体上绘制一个列表框

来源:百度知道 编辑:UC知道 时间:2024/05/25 09:54:37
在窗体上绘制一个列表框,名为List1,通过属性窗口向列表框中添加4个项目,分别为Item1、Item2、Item3和Item4。编写适当的事件过程,使程序运行后,若单击列表框中某一项则该项就从列表框中消失。

i=0
while i<list1.getitemcount()
if list1.itemselected(i) then
list1.removeitem(i)
end if
wend

Private Sub List1_Click()
List1.RemoveItem List1.ListIndex
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.ListBox1.Items.Remove(Me.ListBox1.SelectedItem)
End Sub
//vb.net2005编的

Private Sub Form_Load()
List1.AddItem "Item1"
List1.AddItem "Item2"
List1.AddItem "Item3"
List1.AddItem "Item4"
End Sub

Private Sub List1_Click()
List1.RemoveItem List1.ListIndex
End Sub