Click here to Skip to main content
Click here to Skip to main content

Make CheckBox Read Only

By , 9 Jul 2012
 

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.

//
// On Check Changed event 
//
if (checkBox.Checked == true || checkBox.Checked == false)
{
    checkBox.CheckState = CheckState.Checked; 
    checkBox.CheckState = CheckState.Indeterminate;
    //or 
    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

  • 08-07-2012

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Sanjeeev Kumar Sasode
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 2memberHekmat906 Apr '13 - 18:27 
GeneralAutocheck Property [modified]memberJohn R Hodgson16 Jul '12 - 13:43 
QuestionCode?memberJames Hurburgh10 Jul '12 - 15:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130513.1 | Last Updated 9 Jul 2012
Article Copyright 2012 by Sanjeeev Kumar Sasode
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid