How to do the textbox Disable and Enable effect

keigo

Active member
Joined
Oct 27, 2008
Messages
29
Programming Experience
Beginner
I am new at VB.NET. Sorry, if my question is too easy or ridiculous. Actually I am trying to make some of the textboxes in my form to be able to key in data only when user select a checkbox. For example, user will not be able to key in data into the text boxes,i.e. Name, Address if they do not select a checkbox given. The textboxes should be viewable but it is in grey (or something) like it is locked if the checkbox is not checked. How do I achieve this?

Is my question clear?
Thank you.

:)
 
Is programming involved? I just do not understand how I should handle the checkchanged.

And by enabling the property of my textboxes to the ones as my checkbox's is - how should I accomplish this?

I am slow at this. I am still trying to figure out, if you are free, please elaborate your last message.

Thank you very much :)
 
I have solved this problem. Here is what I do:


Textbox1.Enabled = True

I put the above within the CheckChanged of Check Box.
 
Here's an example:
VB.NET:
Private Sub Checkbox1_CheckedChanged (...) Handles Checkbox1.CheckedChanged
  Textbox1.Enabled = Checkbox1.Checked
End Sub
This means that if the checkbox is checked, the textbox will be enabled, but if the user unchecks the checkbox then the textbox becomes disabled
 
Hi JuggaloBrotha,

Thanks, I have made another approach. I use true instead of checkchanged.

And I use If checkchanged = False, I would clear all the textboxes and put back some default texts back in a textbox. The codes are longer. But I would keep your code in case I would use it in the near future.

Thank you.
 
Back
Top