Need some help with syntax

rahavtom

Regular
Joined
Apr 2, 2004
Messages
63
Hello all !

I have a CheckedLiskBox control on my form. I would like to "run" on this control and enter each item of it into a dataset table.
I 'run' on it this way:

Dim o As Object
For Each o In frmExam.clbSystemsHead.Items
With dsSystemsReviewDetails.Tables("SystemsReviewDetails")
Dim drSystemsReviewDetails As DataRow = .NewRow
drSystemsReviewDetails("Id") = frmExam.txtID.Text
drSystemsReviewDetails("boolean") = ???
.Rows.Add(drSystemsReviewDetails)
End With
Next

What I don't know is how do I know if the current item in the loop is selected or not. I mean, if the item is checked in the CheckedListBox, I wan't it to be checked in the dataset...

Does anyone can help me with the syntax to make it??

Thanks!
Tom.
 
I'm lost as to what your asking, but if your trying to find out if the check box is checked just put:

variable = Item.Checked
 
bri189a said:
I'm lost as to what your asking, but if your trying to find out if the check box is checked just put:

variable = Item.Checked


Hi!

There is no checked property for this control... I'm talking about a CheckedListBox control. This is not like a normal checkbox when you can check the control's status by the 'checked' proberty.
It's more lie a listbox. I want to check with a loop each item in the list, and check if it's checked or not (look at my exaple). I hope I made it clearer... but thanks anyway.
 
The checkedlist box has a CheckedItems collection and that has a .Contains function that accecpts an Object as a parameter. It looks through the items in the listbox that are "Checked" and if it finds the specified item, return true. Obviously, if it does not find the item it returns false. Your code should look like this...

Visual Basic:
For Each o As Object In frmExam.clbSystemsHead.CheckedItems
    'Do your stuff...
Next
 
Last edited:
Mothra said:
The checkedlist box has a CheckedItems collection and that has a .Contains function that accecpts an Object as a parameter. It looks through the items in the listbox that are "Checked" and if it finds the specified item, return true. Obviously, if it does not find the item it returns false. Your code should look like this...

Visual Basic:
For Each o As Object In frmExam.clbSystemsHead.CheckedItems
    'Do your stuff...
Next

OK !
It works perfect.... thanks a lot!
 
Back
Top