Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read-only (visually) CheckBox

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.

Question: how to make checkbos visually appears as read-only ?

Could think about possible solutions:

  • Make 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).
  • Use different control. Which one? 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.
  • Making own component. Drawing the whole 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?

like image 521
Sinatr Avatar asked Nov 11 '13 09:11

Sinatr


People also ask

Can you make a checkbox readonly?

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.

How do I make a non editable checkbox in HTML?

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.

How do you make a checkbox read-only in WPF?

Answers. If you don't need to process any user clicks on the CheckBox, setting IsHitTestVisible="false" should work.


1 Answers

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

  • appears disabled with gray text
  • prevents the Checked value from changing when clicked
  • supports a Tooltip
like image 67
Ed Chapel Avatar answered Sep 20 '22 15:09

Ed Chapel