By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,874 Members | 1,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,874 IT Pros & Developers. It's quick & easy.

Disabled Control Font Colour change?

P: n/a
Bob
Hi,
Is it possible to change the forecolor of a disabled text control.
I have a RichText Box that I don't want the user to edit but the Grey on
Grey default is hard to read.
Is there a way of overriding this with a custom colour?
I had a quick foray into the forms Paint event handler but no joy.
Thanks
Bob
Aug 24 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

Bob wrote:
Hi,
Is it possible to change the forecolor of a disabled text control.
I have a RichText Box that I don't want the user to edit but the Grey on
Grey default is hard to read.
Is there a way of overriding this with a custom colour?
I had a quick foray into the forms Paint event handler but no joy.
Thanks
Bob
Well, TextBox has a ReadOnly property, which sounds like exactly what
you want. Unfortunately, RichTextBox doesn't have ReadOnly.

I solved this problem for ComboBox by creating my own

public class ComboBoxWithReadOnly : ComboBox

and then adding the new property, along with the appropriate code to
intercept keypresses, pastes, and cuts if ReadOnly is true. The
advantage of this approach, as well, is that the user is still free to
Copy text from the control (which they couldn't do if it were
disabled)... they just can't change it.

BTW, this approach is also useful for ListViews and the like, for which
the disabled control (stupidly) can't be scrolled. So if you want your
user to be able to scroll and see everything inside the control but
don't want to allow changes, disabling the control is a non-starter.

Aug 25 '06 #2

P: n/a
Bob
Hi Bruce,
Thank you.
Didn't realise disabling killed scrolling.
Pull up! PullUp!
Shall go the intercept way.
Regards
Bob
"Bruce Wood" <br*******@canada.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
Bob wrote:
Hi,
Is it possible to change the forecolor of a disabled text control.
I have a RichText Box that I don't want the user to edit but the Grey on
Grey default is hard to read.
Is there a way of overriding this with a custom colour?
I had a quick foray into the forms Paint event handler but no joy.
Thanks
Bob

Well, TextBox has a ReadOnly property, which sounds like exactly what
you want. Unfortunately, RichTextBox doesn't have ReadOnly.

I solved this problem for ComboBox by creating my own

public class ComboBoxWithReadOnly : ComboBox

and then adding the new property, along with the appropriate code to
intercept keypresses, pastes, and cuts if ReadOnly is true. The
advantage of this approach, as well, is that the user is still free to
Copy text from the control (which they couldn't do if it were
disabled)... they just can't change it.

BTW, this approach is also useful for ListViews and the like, for which
the disabled control (stupidly) can't be scrolled. So if you want your
user to be able to scroll and see everything inside the control but
don't want to allow changes, disabling the control is a non-starter.

Aug 25 '06 #3

P: n/a
Bob
Hi Bruce,
Turns out that the rtb does have a readonly property!

regards
bob
"Bruce Wood" <br*******@canada.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
Bob wrote:
Hi,
Is it possible to change the forecolor of a disabled text control.
I have a RichText Box that I don't want the user to edit but the Grey on
Grey default is hard to read.
Is there a way of overriding this with a custom colour?
I had a quick foray into the forms Paint event handler but no joy.
Thanks
Bob

Well, TextBox has a ReadOnly property, which sounds like exactly what
you want. Unfortunately, RichTextBox doesn't have ReadOnly.

I solved this problem for ComboBox by creating my own

public class ComboBoxWithReadOnly : ComboBox

and then adding the new property, along with the appropriate code to
intercept keypresses, pastes, and cuts if ReadOnly is true. The
advantage of this approach, as well, is that the user is still free to
Copy text from the control (which they couldn't do if it were
disabled)... they just can't change it.

BTW, this approach is also useful for ListViews and the like, for which
the disabled control (stupidly) can't be scrolled. So if you want your
user to be able to scroll and see everything inside the control but
don't want to allow changes, disabling the control is a non-starter.

Aug 25 '06 #4

P: n/a

Bob wrote:
Hi Bruce,
Turns out that the rtb does have a readonly property!

regards
bob
Gosh darn. Now why didn't I see that in my local Visual Studio help...?

Aug 25 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.