Groups | Blog | Home
all groups > c# > june 2004 >

c# : Checkboxes in C#



jim.ferris NO[at]SPAM motorola.com
6/18/2004 10:36:07 PM
Im trying to create 2 check boxes, but only one can be checked at a
time or none can be checked..

I know radio buttons are used for this functionality but I need to be
able to unchecked them as well so that neither are checked...any
ideas?

thanks

Nick Malik
6/19/2004 5:50:53 AM
sure, in the checked event of each check box, do the following logic

If the current box is checked, uncheck the other.

That way, you can never have both checked, but you can have both unchecked.

It's fairly simple, really.

--- Nick

[quoted text, click to view]

Jon Skeet [C# MVP]
6/19/2004 6:46:26 AM
[quoted text, click to view]

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
Jon Skeet [C# MVP]
6/19/2004 6:53:24 AM
[quoted text, click to view]

Apologies - I'd thought you'd somehow got your checkboxes into that
state accidentally, and didn't know how. Nick's answer is probably the
one you want :)

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
AddThis Social Bookmark Button