Introduction
CheckBox read only is a simple user control that groups a number of related controls.
Background
I'm always striving to improve my user interfaces. A common user interface approach is to present an option (for example: "Save to backup
file") as a check box, with some additional related settings (e.g., an EditBox containing the filename to write to and a 'browse' button). Most
conventional user interfaces either:
- Leave the settings editable (argh!) when the main option is disabled, or
- Disable the controls, only enabling them if the main option is first checked.
Let's make things better... When the controls are disabled, why should the user have to click the CheckBox to make them editable? If they click on a child TextBox we can infer
that they wish to edit it, which requires the main option to be enabled; so why don't we save them some time and do that for them?
Using the code
The article code contains code to make a check box read only.
if (checkBox.Checked == true || checkBox.Checked == false)
{
checkBox.CheckState = CheckState.Checked;
checkBox.CheckState = CheckState.Indeterminate;
checkBox.CheckState = CheckState.Checked;
}
Points of Interest
A good User Interface is all about attention to detail, streamlining user workflows to make it quick and easy to use an application, and
adhering to intuitive standards to avoid confusing users. Even tiny features like those provided by the CheckBox can really improve the user experience.
Automating this type of UI enhancement also saves a lot of programmer time - you have the initial cost of developing a generic solution, but
it pays back over the months and years as you find yourself re-using the same code to save time on every application you write.
History