471,616 Members | 1,077 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

Changing TextBox BackColor / ForeColor When Disabled

When you make a textbox control disabled ( txtText1.Enabled = false; )

You're left with grey text on a greyer background, which is not ideal. The
Read-Only property is no use to me as I need to prevent complete access, so
i've been trying to change the visual display of a control once I have
disabled it and discovered the following.

You can change the back color of a disabled control. (txtText1.BackColor =
System.Drawing.SystemColors.Window;) which improves readability, but I can't
change the forecolor of the control!

Does anybody know why and more importantly how can I change this behaviour
to prevent disabled controls being grey on greyer.

Many thanks

Steve Le Monnier
Nov 16 '05 #1
3 33676
Steve,

The most simple method that came in my mind is hide the textbox and show a
label with the same text on that place.

Cor
Nov 16 '05 #2
I havent seen a solution to this problem which I have seen asked before (
Though there propably is one somewhere ). But there are several alternative
approaches. you could take.

One approach might be to create a user control with a public property to
enable or disable the control. Then you could have a text property to set a
label and text box simeltaniously. The basic idea is that the two controls
would switch visability depending on if the control was enabled.

HTH

--
Terry Burns
http://TrainingOn.net
"Steve Le Monnier" <st*********@nospam.please.hotmail.com> wrote in message
news:e2**************@TK2MSFTNGP14.phx.gbl...
When you make a textbox control disabled ( txtText1.Enabled = false; )

You're left with grey text on a greyer background, which is not ideal. The
Read-Only property is no use to me as I need to prevent complete access,
so i've been trying to change the visual display of a control once I have
disabled it and discovered the following.

You can change the back color of a disabled control. (txtText1.BackColor =
System.Drawing.SystemColors.Window;) which improves readability, but I
can't change the forecolor of the control!

Does anybody know why and more importantly how can I change this behaviour
to prevent disabled controls being grey on greyer.

Many thanks

Steve Le Monnier

Nov 16 '05 #3
hi,

AFAIK there is no way of doing it, you would have either subclass the
textbox and handle the onpaint you self or when the textbox is disabled
change it for other control, like a Label.

no idea even if this is allowed in 2.0 , will check though.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Steve Le Monnier" <st*********@nospam.please.hotmail.com> wrote in message
news:e2**************@TK2MSFTNGP14.phx.gbl...
When you make a textbox control disabled ( txtText1.Enabled = false; )

You're left with grey text on a greyer background, which is not ideal. The
Read-Only property is no use to me as I need to prevent complete access,
so i've been trying to change the visual display of a control once I have
disabled it and discovered the following.

You can change the back color of a disabled control. (txtText1.BackColor =
System.Drawing.SystemColors.Window;) which improves readability, but I
can't change the forecolor of the control!

Does anybody know why and more importantly how can I change this behaviour
to prevent disabled controls being grey on greyer.

Many thanks

Steve Le Monnier

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mike | last post: by
2 posts views Thread by Brian P. Bailey | last post: by
3 posts views Thread by Mad Scientist Jr | last post: by
3 posts views Thread by Eric Moreau | last post: by
2 posts views Thread by ismaelf | last post: by
1 post views Thread by XIAOLAOHU | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.