473,378 Members | 1,609 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,378 software developers and data experts.

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 33885
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
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
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
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
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
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
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
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
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
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.