Home All Groups Group Topic Archive Search About

Need to check a checkbox in a checkedlistbox at run time

Author
23 May 2006 8:13 PM
akunuri.swapna
Hi All - I have a checkedListBox in my form. I am adding items to it at
run time. However I also need to check the items depending on a
condition. I have tried a lot but cant get the added item to check.
Here is my code.

Dim objdb As New clsDB
        PaymentOptions = objdb.GetPaymentOptionsByProductID
        Dim objrowPaymentOptions As DataRow
        For Each objrowPaymentOptions In PaymentOptions.Tables(0).Rows
                Dim string1 as string =
CType(objrowPaymentOptions.Item("is_default"), String)

checkedListBox1.Items.Add(CType(objrowPaymentOptions.Item("new_item"),
String))
        If string1 = "Y" Then
..............Code to check the item added above......

       End If
        next

I hope you got my question.
Anyone please help.


Thanks
Riaz

Author
24 May 2006 8:09 AM
Peter Proost
Hi you can use one of the overloads of the items.add to specify if the item
is checked or not.
checkedListBox1.Items.Add("X",true)

Hope this helps

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

<akunuri.swa***@gmail.com> schreef in bericht
Show quoteHide quote
news:1148415197.166820.298170@j33g2000cwa.googlegroups.com...
> Hi All - I have a checkedListBox in my form. I am adding items to it at
> run time. However I also need to check the items depending on a
> condition. I have tried a lot but cant get the added item to check.
> Here is my code.
>
> Dim objdb As New clsDB
>         PaymentOptions = objdb.GetPaymentOptionsByProductID
>         Dim objrowPaymentOptions As DataRow
>         For Each objrowPaymentOptions In PaymentOptions.Tables(0).Rows
>                 Dim string1 as string =
> CType(objrowPaymentOptions.Item("is_default"), String)
>
> checkedListBox1.Items.Add(CType(objrowPaymentOptions.Item("new_item"),
> String))
>         If string1 = "Y" Then
> .............Code to check the item added above......
>
>        End If
>         next
>
> I hope you got my question.
> Anyone please help.
>
>
> Thanks
> Riaz
>
Author
26 May 2006 6:34 PM
swaps30
That helped .. Thanks Peter