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);
精彩评论