We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Changing to color of textbox when disabled

When I set a TextBox to Readonly or set Enabled to false, the text color is gray. How can I force it to be the color specified in the ForeColor property of the TextBox. How would I do this in VB.net?

1 Reply

CB Clay Burch Syncfusion Team June 1, 2002 07:45 PM UTC

For readonly, if you set the BackColor AFTER you set the ReadOnly property, then the cell will not look gray. For Enabled = False, setting the BackColor will not get rid of the gray text, but will take care of the gray background. For a disabled cell, if you really need to control the forecolor (& not just the backcolor), then one way to do this is to derive your own TextBox, override OnPaint and draw the text yourself using the paintevent arg passed in. This is doable, and works. You have to set the control's style to UserPaint with SetStyle in the constructor.

Loader.
Up arrow icon