Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

Disabled Control Font Colour change?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 25 Aug 2006 00:16 GMT
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
Bruce Wood - 25 Aug 2006 01:17 GMT
> Hi,
> Is it possible to change the forecolor of a disabled text control.
[quoted text clipped - 4 lines]
> 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.
Bob - 25 Aug 2006 01:55 GMT
Hi Bruce,
Thank you.
Didn't realise disabling killed scrolling.
Pull up! PullUp!
Shall go the intercept way.
Regards
Bob

> > Hi,
> > Is it possible to change the forecolor of a disabled text control.
[quoted text clipped - 22 lines]
> 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.
Bob - 25 Aug 2006 02:45 GMT
Hi Bruce,
Turns out that the rtb does have a readonly property!

regards
bob

> > Hi,
> > Is it possible to change the forecolor of a disabled text control.
[quoted text clipped - 22 lines]
> 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.
Bruce Wood - 25 Aug 2006 06:28 GMT
> 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...?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.