I need to have 2 groups of controls on the screen: inputs and outputs (so they have 2 states: On or Off). Thus CheckBox
seems to be a good choice. Checking any output will set it.
However, when displaying inputs there will be no user interaction with it. User is only allowed to see its value, not to change it.
Could think about possible solutions:
CheckBox
disabled. Bad: there will be no tooltip (possible to solve it? by fake panel on top?) and visually disabled CheckBox
is not nice (and I don't want to make user think it is disabled).Label
doesn't have nice placeholder for the On/Off value. RadioButton
look differently, but they usually means there is a single choice out of many, while values of inputs are independent.CheckBox
is a bit overkill (and honestly, I don't know how to do it to have Win7 appearance). Would it be possible to add only ReadOnly
appearance to the box part easily?What do you guys think?
Learn how client-side enable expressions can be used to disable a checkbox, making it readonly. A checkbox HTML element doesn't have a "readonly" property. Consequently, the only way to make a checkbox appear to be "readonly" is to disable the control.
The readonly attribute can be set to keep a user from changing the value until some other conditions have been met (like selecting a checkbox, etc.). Then, a JavaScript can remove the readonly value, and make the input field editable.
Answers. If you don't need to process any user clicks on the CheckBox, setting IsHitTestVisible="false" should work.
There is a solution that is combination of the existing answers.
checkBox.ForeColor = Color.Gray; // Read-only appearance
checkBox.AutoCheck = false; // Read-only behavior
// Tooltip is possible because the checkbox is Enabled
var toolTip = new ToolTip();
toolTip.SetToolTip(checkBox, "This checkbox is read-only.");
The result is a CheckBox
that
Checked
value from changing when clickedTooltip
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