Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
With ListBox1
For i = 1 To 10
.Items.Add("cctv" & i)
Next
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'重点在这里
Dim o
'选择每一个 list1 选中的元素
For Each o In ListBox1.SelectedItems
'添加到 listbox2
With ListBox2
.Items.Add(o)
End With
Next
End Sub
End Class
AutoPostBack设置为True,SelectedIndexChanged事件里写提示代码:
For Each li As ListItem In CheckBoxList.Items
If (li.text == "a" and li.Checked) Then
msgbox("a")
End If
If (li.text == "b" and li.Checked) Then
msgbox("b")
End IfNext