473,513 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing TextBox BackColor / ForeColor When Disabled

When you make a textbox control disabled ( txtText1.Enabled = false; )

You're left with grey text on a greyer background, which is not ideal. The
Read-Only property is no use to me as I need to prevent complete access, so
i've been trying to change the visual display of a control once I have
disabled it and discovered the following.

You can change the back color of a disabled control. (txtText1.BackColor =
System.Drawing.SystemColors.Window;) which improves readability, but I can't
change the forecolor of the control!

Does anybody know why and more importantly how can I change this behaviour
to prevent disabled controls being grey on greyer.

Many thanks

Steve Le Monnier
Nov 16 '05 #1
3 33899
Steve,

The most simple method that came in my mind is hide the textbox and show a
label with the same text on that place.

Cor
Nov 16 '05 #2
I havent seen a solution to this problem which I have seen asked before (
Though there propably is one somewhere ). But there are several alternative
approaches. you could take.

One approach might be to create a user control with a public property to
enable or disable the control. Then you could have a text property to set a
label and text box simeltaniously. The basic idea is that the two controls
would switch visability depending on if the control was enabled.

HTH

--
Terry Burns
http://TrainingOn.net
"Steve Le Monnier" <st*********@nospam.please.hotmail.com> wrote in message
news:e2**************@TK2MSFTNGP14.phx.gbl...
When you make a textbox control disabled ( txtText1.Enabled = false; )

You're left with grey text on a greyer background, which is not ideal. The
Read-Only property is no use to me as I need to prevent complete access,
so i've been trying to change the visual display of a control once I have
disabled it and discovered the following.

You can change the back color of a disabled control. (txtText1.BackColor =
System.Drawing.SystemColors.Window;) which improves readability, but I
can't change the forecolor of the control!

Does anybody know why and more importantly how can I change this behaviour
to prevent disabled controls being grey on greyer.

Many thanks

Steve Le Monnier

Nov 16 '05 #3
hi,

AFAIK there is no way of doing it, you would have either subclass the
textbox and handle the onpaint you self or when the textbox is disabled
change it for other control, like a Label.

no idea even if this is allowed in 2.0 , will check though.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Steve Le Monnier" <st*********@nospam.please.hotmail.com> wrote in message
news:e2**************@TK2MSFTNGP14.phx.gbl...
When you make a textbox control disabled ( txtText1.Enabled = false; )

You're left with grey text on a greyer background, which is not ideal. The
Read-Only property is no use to me as I need to prevent complete access,
so i've been trying to change the visual display of a control once I have
disabled it and discovered the following.

You can change the back color of a disabled control. (txtText1.BackColor =
System.Drawing.SystemColors.Window;) which improves readability, but I
can't change the forecolor of the control!

Does anybody know why and more importantly how can I change this behaviour
to prevent disabled controls being grey on greyer.

Many thanks

Steve Le Monnier

Nov 16 '05 #4

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

Similar topics

1
5954
by: Mike | last post by:
I would like to change the back color on a Text Box on a Access97 Form.... I have a formula in the text box that adds up in Currency... =+.... the format is this +$#,###.00;-$#,###.00 to show...
2
19710
by: Brian P. Bailey | last post by:
I would like to: 1] Output messages to a user in a scrollable control 2] Allow the user to copy selected text from this control 3] The user should be prevented from modifying the text in any way...
3
15386
by: Mad Scientist Jr | last post by:
Can someone post a clear example of how to change the background color of an individual datagrid cell for a Windows desktop app? (preferably in vb.net) I found some code on how to do this when...
3
8970
by: Eric Moreau | last post by:
Hi I have a user that is visually impaired and who cannot read textboxes content when they are disabled. I have tried to inherits from the Textbox and overwrite the Paint method but I have...
2
2967
by: ismaelf | last post by:
i have a textbox in a template column in a datagrid, it displays the initial value of the row, but when i change it remains with the original value (it doesnt get the new value..) i fill the...
0
2387
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
1
1505
by: preeti13 | last post by:
hey i am trying to put the textbox column inside the datagrid but i don't have any idea how to do that please any one help me with this my code is like this: <asp:datagrid id="garidreason"...
0
3549
by: rehanmomin | last post by:
Just to start off, I am writing a web application using C#. I have a Menu which is binded to an XML datasource. There are three menu items each with submenus and a textbox where I want to display...
8
30013
by: hiranmaie | last post by:
Hi, I am having 3 textboxes and 1 gridview. I want to pass (reflect) the values from textboxes to gridview. I am not using the database here. I want to save the data directly from textboxes...
0
7175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
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,...
0
7542
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...
1
5100
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...
0
4754
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...
0
3247
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...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1609
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 ...
0
466
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.