read only check box

jsn1

Member
Joined
Jul 14, 2006
Messages
12
Programming Experience
10+
Hi all

there is a property in a textbox that allows to set a text box in read only mode. how can I do the same thing in a check box?

I have an update form, where I only want the user to update some fields, not all of them. The Check box files must be read only

thanks
 
Last edited:
Read only checkbox, well as you've already discovered there is no readonly property, but there is an enabled property.Set the enabled to false, then i believe you can still modify the checked property in code and the control will update accordingly.
 
Either in the designer, in the properties window goto the enabled property and change it to false.
Or you can do it a runtime -

VB.NET:
Checkbox.Enabled = false
 
ReadOnly checkbox

If you set CheckBox.Enabled = False it will be greyed out and its text will be hard to read.
I'd suggest to set its Checked property to desired value on _Click event.
For example, if you want to keep it checked regardless of user actions use the following code:

Private Sub CheckBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Click
CheckBox1.Checked =
True
End Sub

Regards,
Greg
 
Thats definatley another option, but the enabled property has been around for a while, and i've never had any problems reading it. But both options will work.
 
I just encountered the same challenge while doing some homework in a beginner's course.

The purpose of this problem is to use menus to carry out sub procedures, but the problem asks me to have checks marks and radio buttons next to the various options, so that the user can tell which options are displayed and which are not.

I don't want to have the checkboxes enabled because having checkboxes and radio buttons that don't do anything looks sloppy and is confusing.

But I also don't like how disabling the entire control looks, so I got creative with my interface.

I disabled the checkboxes, but then put independent labels right next to the disabled checkboxes. That way, the text labels are not grayed out but the checkboxes are "read-only".

eprx2f.jpg





That's my spin on creating a read-only checkbox.


Cheers,
Kayce A. Basques
 
Psuedo "Read-Only" for vb.net checkbox

Hi all

there is a property in a textbox that allows to set a text box in read only mode. how can I do the same thing in a check box?

I have an update form, where I only want the user to update some fields, not all of them. The Check box files must be read only

thanks



I set the CheckBox property: "AutoCheck" to "False". Then I make sure there are no "Click" handlers for that CheckBox. At runtime, the user can "Click" all they want, and it won't change.

You can use this same methodology to handle validating conditions in order to "Check" a box. Just write the "Click" handler to do the check and then update the box.

Hope this helps.

Gryphon...
 
Back
Top