Visual Basic 2008 中 checkedlistbox控件用法

Public Class Form3

Private Sub 载入数据_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 载入数据.Click
Dim i As Integer
For i = 1 To 10
CheckedListBox1.Items.Add(i)
Next
End Sub

Private Sub 显示选中_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 显示选中.Click
Dim i As Integer
For i = 0 To CheckedListBox1.Items.Count - 1
If CheckedListBox1.GetItemChecked(i) Then
MsgBox(CheckedListBox1.Items(i))
End If
Next
End Sub
End Class

精典:

显示选中的项目


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For i = 0 To CheckedListBox1.CheckedItems.Count - 1
MsgBox(CheckedListBox1.CheckedItems(i))
Next
End Sub

你可能感兴趣的:(checked)