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 / Windows Forms / WinForm General / April 2006

Tip: Looking for answers? Try searching our database.

How to change all disabled controls backcolor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Toze - 03 Apr 2006 17:51 GMT
I need to change the color used by windows to paint the backcolor of all
disabled controls in my application, because users, in certain conditions of
light, can't read the text.
I Think that I need to change something like SystemColors.GrayText, but it
seems to be readonly...
My application was developed using C# 2005.

Thank you
mikeq - 03 Apr 2006 18:32 GMT
Try this:

           foreach (Control c in this.Controls)
           {
               if(c.enabled == false)
                   c.BackColor = Color.Black;
           }

-- Mikeq

> I need to change the color used by windows to paint the backcolor of all
> disabled controls in my application, because users, in certain conditions of
[quoted text clipped - 4 lines]
>
> Thank you
Toze - 03 Apr 2006 19:03 GMT
Hi Mikeq,

If possible, I would prefer to change the backcolor used by windows to paint
disabled controls instead of iterating all controls and setting their
backcolor.

My application has many forms, so I'm afraid that if I had to code
everywhere a control enabled state can change (to enabled or disabled) my
source code will turn very heavy and error prone.

Is it possible to change the value of SystemColors.GrayText ? I know in
VS2005 it is readonly but maybe you can help me with some code to achieve
this result.

Thanks

> Try this:
>
[quoted text clipped - 14 lines]
> >
> > Thank you
mikeq - 03 Apr 2006 19:15 GMT
Sorry Toze, I don't know how to do that. I would put the suggested code in
each form.Load() function. I underestand you have many forms, so I would also
define a global variable that represents the color that you want so that you
can change it in just one place.

Color myDisabledColor = Color.Whatever;
...
Form.Load()
{
   foreach(Control c in this.Controls)
   {
        if(c.enabled == false)
        c.BackColor = myDisabledColor;
   }
}

-- Mikeq

> Hi Mikeq,
>
[quoted text clipped - 30 lines]
> > >
> > > Thank you
Stoitcho Goutsev (100) - 03 Apr 2006 21:14 GMT
Toze,

This is not possible. This is system wide setting and cannot be controlled
for one application only. As Mikeq said you can control this on per control.

Signature

Stoitcho Goutsev (100)

> Hi Mikeq,
>
[quoted text clipped - 34 lines]
>> >
>> > Thank you

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.