Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted
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.

Posted (edited)

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...

 

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

Edited by Mothra
Being smarter than you look is always better than looking smarter than you are.
Posted
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...

 

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

 

OK !

It works perfect.... thanks a lot!

  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...