Grouped Check Boxes
-
Can you group together CheckBoxes so only one in a group is checked at one time and if so How?
Winforms or ASP.NET? If Winforms: Use RadioButtons instead of CheckBoxs. Put them in a GroupBox or Panel and they'll automatically be mutually exclusive. :josh: My WPF Blog[^]
-
Winforms or ASP.NET? If Winforms: Use RadioButtons instead of CheckBoxs. Put them in a GroupBox or Panel and they'll automatically be mutually exclusive. :josh: My WPF Blog[^]
-
Can you group together CheckBoxes so only one in a group is checked at one time and if so How?
You deserve to be thrown off a cliff for doing so. Check box are designed so you can select multiple. Options are designed to choose. Switching the two will only confuse people. That said, create a collection of all of the check boxes you want to enforce one check only. Add a listener to all the check boxes for CheckedChanged to the same method. In the method loop through all of the check boxes in the collection if the sender object is a check box that is true and set all other check boxes to unchecked. A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane
-
You deserve to be thrown off a cliff for doing so. Check box are designed so you can select multiple. Options are designed to choose. Switching the two will only confuse people. That said, create a collection of all of the check boxes you want to enforce one check only. Add a listener to all the check boxes for CheckedChanged to the same method. In the method loop through all of the check boxes in the collection if the sender object is a check box that is true and set all other check boxes to unchecked. A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane
private void checkBox_CheckedChanged(object sender, EventArgs e) {
if(sender is CheckBox){
if(((CheckBox)sender).Checked){
foreach(CheckBox ck in list){
if(ck != sender){ //Object comparison
ck.Checked = false;
}
}
}
}
}A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane
-
You deserve to be thrown off a cliff for doing so. Check box are designed so you can select multiple. Options are designed to choose. Switching the two will only confuse people. That said, create a collection of all of the check boxes you want to enforce one check only. Add a listener to all the check boxes for CheckedChanged to the same method. In the method loop through all of the check boxes in the collection if the sender object is a check box that is true and set all other check boxes to unchecked. A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane
-
Winforms, and i can't use Radion buttons because i am looking for the sticky button look that a check box has.
Your users will be confused by mutually exclusive checkboxes. It's atypical and, hence, weird. When it comes to UIs, stick to conventions unless you have a very good reason not to. :josh: My WPF Blog[^]
-
Winforms, and i can't use Radion buttons because i am looking for the sticky button look that a check box has.
What the hell is "sticky button look"? Can I use that next time I'm at the pool?
Try code model generation tools at BoneSoft.com.