Hum, im wondering how would i tell if user checked a box in the CheckList Box?
Im going to have alot so i need to keep it neet and tidy so it looks clean.
Thanks!
Printable View
Hum, im wondering how would i tell if user checked a box in the CheckList Box?
Im going to have alot so i need to keep it neet and tidy so it looks clean.
Thanks!
CheckedListBoxes have a special collection called "CheckedIndexes" which you can check the count of to see if anything is checked. I'm not 100% sure of the name of that collection is "CheckedIndexes" but it's something like that.
CheckedListBox has 2 accessible properties to check for checked items: CheckedIndices() and CheckedItems(). Both properties point to different collection classes and are made to check using indices (integers) or items. :)
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click With CheckedListBox1 If .CheckedItems.Count > 0 Then For i As Integer = .CheckedItems.Count - 1 To 0 Step -1 'for this example I am adding what has been checked to 'a separate listbox. You do, here, whatever you need 'to do for any item that has been checked ListBox1.Items.Add(.CheckedItems(i)) Next End If End With End Sub