Disabled Control Font Colour change?

B

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
 
B

Bruce Wood

Bob said:
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.
 
B

Bob

Hi Bruce,
Thank you.
Didn't realise disabling killed scrolling.
Pull up! PullUp!
Shall go the intercept way.
Regards
Bob
 
B

Bruce Wood

Bob said:
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...?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top