Home All Groups Group Topic Archive Search About

Checklist box code help needed

Author
20 Aug 2006 3:04 AM
John
Hi

I have a check list box.When user selects a specific value '(All)' I want to
uncheck all other check boxes in the list. How can I achieve this in code?

Thanks

Regards

Author
20 Aug 2006 7:56 AM
Cor Ligthert [MVP]
Tom,

If you detect that the all is checked than

remove the handler from the check event (or what you use)
than uncheck all boxes in a loop
check the all box again
add the handler again

And it is done,

If you want some sample code, than show at least the event that you are now
using.

I hope this helps,

Cor

Show quoteHide quote
"John" <John@nospam.infovis.co.uk> schreef in bericht
news:%23zM7zVAxGHA.4872@TK2MSFTNGP02.phx.gbl...
> Hi
>
> I have a check list box.When user selects a specific value '(All)' I want
> to uncheck all other check boxes in the list. How can I achieve this in
> code?
>
> Thanks
>
> Regards
>
Author
20 Aug 2006 1:02 PM
Lost
"John" <John@nospam.infovis.co.uk> wrote:

>Hi
>
>I have a check list box.When user selects a specific value '(All)' I want to
>uncheck all other check boxes in the list. How can I achieve this in code?

As it happens, I've just been doing something similar.

I'll assume your 'All' item is the top one (item 0).

Try this code:

If CheckedListBox1.GetItemChecked(0) = True Then
   For i = 1 To CheckedListBox1.Items.Count - 1
      CheckedListBox1.SetItemChecked(i, False)
   Next i
End If

--
This is soc.men, we know better. -- Michael Snyder
Author
23 Aug 2006 4:15 PM
John
Thanks This worked. How can I make sure then when of the other options is
clicked then the All option is unticked?

Thanks again

Regards

Show quoteHide quote
"Lost" <lostag***@mailinator.com> wrote in message
news:44e85d72$0$17965$892e7fe2@authen.yellow.readfreenews.net...
> "John" <John@nospam.infovis.co.uk> wrote:
>
>>Hi
>>
>>I have a check list box.When user selects a specific value '(All)' I want
>>to
>>uncheck all other check boxes in the list. How can I achieve this in code?
>
> As it happens, I've just been doing something similar.
>
> I'll assume your 'All' item is the top one (item 0).
>
> Try this code:
>
> If CheckedListBox1.GetItemChecked(0) = True Then
>   For i = 1 To CheckedListBox1.Items.Count - 1
>      CheckedListBox1.SetItemChecked(i, False)
>   Next i
> End If
>
> --
> This is soc.men, we know better. -- Michael Snyder