473,698 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.En abled = 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 1968
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 DisabledBackCol or 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***@discussi ons.microsoft.c om> wrote in message
news:41******** *************** ***********@mic rosoft.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.En abled = 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
2479
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 White to Yellow and then back to White in about 1 second or so. This is to create something like a 'flash' (or a Pulse) for when a User clicks on 1 of 4 Radio Buttons (which change the Text in the TextBox). So in other words, to get the...
3
8813
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 the application changes the color of the background of a textbox. Here the explanation goes: This is a form bound to an SQL view. The detail section has several fields, one of them being a textbox of name "Type". I checked its
3
3624
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 I don't know what exactly it means. What is the meaning of that yellow BG color of ASP:TextBoxes ? How can I have control over it?
2
1896
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? thanks
8
36890
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) { txtDummie.BackColor=Color.Red; }
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.