rahavtom Posted September 13, 2004 Posted September 13, 2004 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. Quote
bri189a Posted September 13, 2004 Posted September 13, 2004 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 Quote
rahavtom Posted September 13, 2004 Author Posted September 13, 2004 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. Quote
Mothra Posted September 13, 2004 Posted September 13, 2004 (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 September 13, 2004 by Mothra Quote Being smarter than you look is always better than looking smarter than you are.
rahavtom Posted September 14, 2004 Author Posted September 14, 2004 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! Quote
meekredd1 Posted August 18, 2008 Posted August 18, 2008 Plz use insert command.it's very easy one Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.