开发者

CheckBox Grouping

I have 4 checkboxes on a winform

I need to group them in such a way that

-> User should be able to check more than one checkboxes

-> User should no开发者_StackOverflow中文版t be allowed to uncheck all the checkboxes,

that is at any point of time atleast one checkbox should be checked,

(I need to somehow prevent user from unchecking last checkboxe)

How do I achieve this?


Use the CheckedChanged event to check the state of the check boxes. Don't allow them to uncheck if there will be none checked.

Also you can have the checkbox controls pointed to the same event using something like below.

chkboxes1.CheckedChanged += new EventHandler(chkboxes_CheckedChanged); chkboxes2.CheckedChanged += new EventHandler(chkboxes_CheckedChanged); chkboxes3.CheckedChanged += new EventHandler(chkboxes_CheckedChanged);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜