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 / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

Background color of TextBox control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve - 04 May 2005 22:29 GMT
I have windows form with the few TextBox controls.
Under certain conditions I disable or enable this controls by setting Enable
property to true or false: For example:

this.m_txtIP.Enabled = false ;

The controller become disabled, and I can't enter any data. The problem is
that the background color of the TextBox doesn't change whether it is enabled
or disabled.
It always looks like enabled.

Can anyone advise me what can prevent background of TextBox from changing
when I disable it? I didn't touch BackColor property of control and assumed
that
background of the control changes automatically, once Enable property is set
to false. Am I wrong?

Thanks
Tamas Demjen - 05 May 2005 18:02 GMT
> Can anyone advise me what can prevent background of TextBox from changing
> when I disable it? I didn't touch BackColor property of control and assumed
> that
> background of the control changes automatically, once Enable property is set
> to false. Am I wrong?

This assumption is probably wrong, although I haven't tried that myself.
I think the background color is determined by the BackColor property,
and most likely you have to change this when you change Enabled. It
would be nice to have a DisabledBackColor property, which would be used
*automatically* when the control is disabled.

You may want to try to write your own event handler that captures the
change of the Enabled property and updates the color accordingly.

Tom
Peter van der Goes - 06 May 2005 13:05 GMT
>I have windows form with the few TextBox controls.
> Under certain conditions I disable or enable this controls by setting
[quoted text clipped - 18 lines]
>
> Thanks

I tested this in a small C# Windows app here, and the background color in a
disabled text box does change automatically here, to the default form color.
Actually, the foreground color changes automatically as well, from a very
dark gray (normal text) to a medium gray. That said, I have no idea why your
behavior differs, unless you have loaded some sort of theme or customs color
template for Windows that is affecting your app? If you are running some
sort of theme, try removing it.

Signature

Peter [MVP Visual Developer]
Jack of all trades, master of none.

Tamas Demjen - 06 May 2005 17:51 GMT
 > The controller become disabled, and I can't enter any data. The
problem is
> that the background color of the TextBox doesn't change whether it is enabled
> or disabled.
> It always looks like enabled.

I just verified it with VS2003 and 2005 Beta 2, and they both change the
background and font colors automatically when the text box gets
disabled. Not at design time, but at runtime certainly. Probably you
expected it to change at design time as well?

Tom

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.