473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Background color of TextBox control

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

Nov 17 '05 #1
3 1956
Steve wrote:
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
Nov 17 '05 #2

"Steve" <St***@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
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

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.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 17 '05 #3

Steve wrote:
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
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Mr. B | last post by:
While at first this may seem a simple tast, it has plagued me for a while... What I want to do is to have the background colour of something like a TextBox to change from (say) White to Yellow to...
3
by: Roberto Castro | last post by:
Hello! I have been assigned for the first time an adp Access project and so far I have managed to make the changes needed for some requirements. However, I am struggling to find the place where...
3
by: A.M | last post by:
Hi, Even I specifically mentioned "white" as background color of all ASP:TextBoxes of my form, Some of them come up with yellow background. I guess it should be kind of ASP.NET behaviour, but...
2
by: James Ramaley | last post by:
Setting the ReadOnly property of my controls changes the background color. The same happens when I set Enabled = False. Where does .NET get the new background color from? Is it configurable? ...
8
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.