Basically, I have a list of delivery checkboxes one for deliver to this address and another for deliver to a separate address, I basically want to make it so once one has been checked the other can not be checked out (perhaps by greying it out or something along those lines)
Please be aware that both boxes use the same controls.
You can style checkbox label and readonly inputs with CSS, e.g.: input [readonly="readonly"] {} but the browser should make the checkbox should appear greyed out when set to readonly. "checkbox itself should appear greyed out just by setting the readonly attribute" - Tried in IE8, FF12.
Use the following code, checkboxToBeGreyed. Enabled = false; You have write this code in other checkbox's checked event .
The disabled property sets or returns whether a checkbox should be disabled, or not. A disabled element is unusable and un-clickable. Disabled elements are usually rendered in gray by default in browsers. This property reflects the HTML disabled attribute.
In checkboxes, for example, you can check them on or off (thus setting the CHECKED state) but you don't change the value of the field.
Listen to the first CheckBox's CheckedChanged event with a method like this one:
private void checkBox1_checkedChanged(object sender, EventArgs e)
{
this.checkBox2.Enabled = !this.checkBox1.Checked;
// If you want it to be unchecked as well as grayed out,
// then have this code as well:
if (!this.checkBox2.Enabled)
{
this.checkBox2.Checked = false;
}
}
But you should consider using RadioButtons instead of CheckBoxes, if it logically fits to your needs.
Use the following code,
checkboxToBeGreyed.Enabled = false;
You have write this code in other checkbox's checked event . Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With