Change backcolor when controls are disable

Hi, how can i change the background color of a textbox and combox when they are disable?
LVL 8
arcrossAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PockyMasterCommented:
There might be an easier solution, but you can override the Paint event, and paint it depending on your enabled status.
0
ZeonFlashCommented:
You can change the backgrounds by using the .BackColor method.  

TextBox1.BackColor = Color.White
ComboBox1.BackColor = Color.White
0
Éric MoreauSenior .Net ConsultantCommented:
see an article I wrote in July 2005 at http://emoreau.s2i.com/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dumpsterdivingdaveCommented:
Private Sub txtmyBox_EnabledChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAddress.EnabledChanged
     If txtMyBox.Enabled = False Then
          txtMyBox.BackColor = Color.Blue
     End If
End Sub


Color.Blue should be changed to whatever color you want.  The code is almost identical for the combo boxes.  To bring this up automatically, just double click your control.  By defaul the function will look like:

Private Sub txtmyBox_TextChanged....

In the upper right will be a drop down box with TextChanged in bold, drop it down and select enabled changed to convert it to the above form...  or just change it manually.  Then, the code contained in it will execute whenever the control switches from enable to disabled or from disabled to enabled.  In the above example, the If statement tells it to only execute if switching from enabled to disabled.  To go from disabled to enabled, just change the true to false.
0
arcrossAuthor Commented:
The backcolor i can change it when the control is disable, (i meant the forecolor,ooops my fault!).

Emoreau, i found your article before i posted this question to see if someone came with something shorter to implement.
But i havent found anything else better than yours!.

Thanks for that article!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.