Senin, 10 Oktober 2011

CheckedListBox

type='html'>Sample Code

Add Object to CheckedListBox

Dim pItem As CarItem

pItem = New CarItem()
pItem.CarId = 1
pItem.CarName="CarName"

' Add this object to CheckListBox
' And CheckListBox show CarName because I override toString function
Me.CheckListBox1.Items.Add(pItem, True)

' Class CarItem

Private Class CarItem

Public CarId As Integer
Public CarName As String

Public Sub New()

End Sub

' Override tostring
Public Overrides Function ToString() As String
Return CarName
End Function

End Class



Get status items in CheckedListBox

For i As Integer = 0 To Me.CheckedListBox.Items.Count - 1
If Me.CheckedListBox.GetItemChecked(i) Then
'TODO Something

End If
Next i

Get only Checked Items

For i As Integer = 0 To Me.CheckedListBox.CheckedItems.Count - 1
'TODO Something
Next



Set all item checked

For i As Integer = 0 To Me.CheckedListBox.Items.Count-1
Me.CheckedListBox.SetItemChecked(i, true)

Next i

CheckedListBox Rating: 4.5 Diposkan Oleh: dragon
Terima kasih sudah berkomentar