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

Button Forecolor When Disabled

Is there a way to leave the button forecolor unchanged when it is
disabled?

I have multiple buttons on the form and depending on various user
inputs, some will or will not be enabled but I'd rather their text not
go to gray.

Thanks.
Sep 30 '08 #1
17 10267
Luckily not, that is standard as users are now expecting it.

We are not living some years after WWII anymore.

Cor

<go********@gmail.comschreef in bericht
news:69**********************************@t41g2000 hsc.googlegroups.com...
Is there a way to leave the button forecolor unchanged when it is
disabled?

I have multiple buttons on the form and depending on various user
inputs, some will or will not be enabled but I'd rather their text not
go to gray.

Thanks.
Sep 30 '08 #2
I'm not sure what to make of your comment. You know nothing of my
users, the purpose of my application, or the environment where it will
be deployed.
Sep 30 '08 #3
<go********@gmail.comwrote in message
news:63**********************************@75g2000h so.googlegroups.com...
I'm not sure what to make of your comment. You know nothing of my
users, the purpose of my application, or the environment where it will
be deployed.
Disabled controls are supposed to have grey text! Just check *any
application in existance*... Disabled menus are grey, disabled option
buttons are grey, disabled checkboxes are grey. Even while typing this
reply, since I haven't selected anything for copy/paste, those buttons are
grey. Just hover your mouse over any menu.

This is a standard that was adopted pre-Windows 3.1, so your users, no
matter who they are, *should* be used to seeing grey buttons.

Now, if you insist on "breaking the rules", no one can stop you. You should
be able to place those buttons inside of a container control and disable the
container, instead of the button. Be prepared for support calls asking
questions like "The button looks available, but when I click it, nothing
happens"

--
Ken Halter
Part time groupie
Sep 30 '08 #4
On Sep 30, 1:22*pm, "Ken Halter"
<Ken_Halter@Use_Sparingly_Hotmail.comwrote:
<govolsb...@gmail.comwrote in message

news:63**********************************@75g2000h so.googlegroups.com...
I'm not sure what to make of your comment. *You know nothing of my
users, the purpose of my application, or the environment where it will
be deployed.

Disabled controls are supposed to have grey text! Just check *any
application in existance*... Disabled menus are grey, disabled option
buttons are grey, disabled checkboxes are grey. Even while typing this
reply, since I haven't selected anything for copy/paste, those buttons are
grey. Just hover your mouse over any menu.

This is a standard that was adopted pre-Windows 3.1, so your users, no
matter who they are, *should* be used to seeing grey buttons.

Now, if you insist on "breaking the rules", no one can stop you. You should
be able to place those buttons inside of a container control and disable the
container, instead of the button. Be prepared for support calls asking
questions like "The button looks available, but when I click it, nothing
happens"

--
Ken Halter
Part time groupie
Sep 30 '08 #5
Thank you Ken for giving me an idea on how to achieve what I'm after.

I think the problem here is that the so called "rules" typically apply
to desktop applications used in home/office environments by regular
people. This is not the case with my application. It is intended for
(and will only be used on) a specialized device by a very small (and
very highly trained) subset of the employee population of my company
in a very non-normal environment (especially in terms of lighting).

So why I can appreciate standards, there will always be exceptions.
This is one of those exceptions.
Sep 30 '08 #6

"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.comwrote in message
news:e4*************@TK2MSFTNGP06.phx.gbl...
>
Now, if you insist on "breaking the rules", no one can stop you. You
should be able to place those buttons inside of a container control and
disable the container, instead of the button.
Did you actually fire up Visual Studio and test that ? I would be expecting
that not to work, rather the enabled status would cascade down to child
controls.

Oct 1 '08 #7
Bill,

Nobody prevents somebody to create his own controls.

However as you say: "I have made this with Visual Studio, then a kind of
standard behaviour is expected". Especially as you don't make it for kids.

It is for me as placing an engine from a Fiat Panda in a Ferrari and then
sell it as a standard Ferrari.

jmo

Cor

"Bill McCarthy" <Bi**@localhost.comschreef in bericht
news:e%****************@TK2MSFTNGP06.phx.gbl...
>
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.comwrote in message
news:e4*************@TK2MSFTNGP06.phx.gbl...
>>
Now, if you insist on "breaking the rules", no one can stop you. You
should be able to place those buttons inside of a container control and
disable the container, instead of the button.

Did you actually fire up Visual Studio and test that ? I would be
expecting that not to work, rather the enabled status would cascade down
to child controls.
Oct 1 '08 #8
I for one hate this standard. It is very common to want a version of a data
entry form that is "read only".

Setting .Enabled=False would be the easiest way to do it, except that in
many cases the controls become unreadable. It is not very clear how Windows
decides what colours to use for these disabled controls.

It's okay that the colours change for disabled controls, what irks me is the
lack of control over what the colours change *to*.

I don't think Cor Ligthert's comment was useful at all. If you can't post
something polite and helpful, don't post at all.

--
David Streeter
Synchrotech Software
Sydney Australia
"Bill McCarthy" wrote:
>
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.comwrote in message
news:e4*************@TK2MSFTNGP06.phx.gbl...

Now, if you insist on "breaking the rules", no one can stop you. You
should be able to place those buttons inside of a container control and
disable the container, instead of the button.

Did you actually fire up Visual Studio and test that ? I would be expecting
that not to work, rather the enabled status would cascade down to child
controls.

Oct 1 '08 #9
No easy way.

You can flip the .BackColor property between SystemColors.Control and (say)
Color.White depending on its .Enabled property to make it more readable.

--
David Streeter
Synchrotech Software
Sydney Australia
"go********@gmail.com" wrote:
Is there a way to leave the button forecolor unchanged when it is
disabled?

I have multiple buttons on the form and depending on various user
inputs, some will or will not be enabled but I'd rather their text not
go to gray.

Thanks.
Oct 1 '08 #10
Hi David,

That won't work. You either need to override the enabled property and stop
it being disabled as such or override the OnPaint method and draw the text
yourself
"SurturZ" <su*****@newsgroup.nospamwrote in message
news:8B**********************************@microsof t.com...
No easy way.

You can flip the .BackColor property between SystemColors.Control and
(say)
Color.White depending on its .Enabled property to make it more readable.

--
David Streeter
Synchrotech Software
Sydney Australia
"go********@gmail.com" wrote:
>Is there a way to leave the button forecolor unchanged when it is
disabled?

I have multiple buttons on the form and depending on various user
inputs, some will or will not be enabled but I'd rather their text not
go to gray.

Thanks.
Oct 1 '08 #11
Hi David,

The colors disabled controls change to is controlled by the sytem's color
schemes. Users can change these based on their monitor and/or visual
impairment they may have. There's also a standard set of schemes such as
high visibility etc. So if you do your own custom thing, you're fighting
against the system and the user ;)

That said, I know there are times you want to display information to the
user, but not allow interaction. I don't think a button is the right choice
there. One simple option might be to hide a button and instead show a label
or show a label over the button is the button is disabled.

Whatever approach you take, it really needs to be tested at a minim against
all the standard windows color schemes and themes (turn themes both on and
off). These days I also try to run the apps with a screen reader to make
sure there's no accessibility issues.

"SurturZ" <su*****@newsgroup.nospamwrote in message
news:E9**********************************@microsof t.com...
>I for one hate this standard. It is very common to want a version of a data
entry form that is "read only".

Setting .Enabled=False would be the easiest way to do it, except that in
many cases the controls become unreadable. It is not very clear how
Windows
decides what colours to use for these disabled controls.

It's okay that the colours change for disabled controls, what irks me is
the
lack of control over what the colours change *to*.

I don't think Cor Ligthert's comment was useful at all. If you can't post
something polite and helpful, don't post at all.

--
David Streeter
Synchrotech Software
Sydney Australia
"Bill McCarthy" wrote:
>>
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.comwrote in message
news:e4*************@TK2MSFTNGP06.phx.gbl...
>
Now, if you insist on "breaking the rules", no one can stop you. You
should be able to place those buttons inside of a container control and
disable the container, instead of the button.

Did you actually fire up Visual Studio and test that ? I would be
expecting
that not to work, rather the enabled status would cascade down to child
controls.

Oct 1 '08 #12
go********@gmail.com wrote:
Is there a way to leave the button forecolor unchanged when it is
disabled?

I have multiple buttons on the form and depending on various user
inputs, some will or will not be enabled but I'd rather their text not
go to gray.
What happens if you use RemoveHandler for its handlers instead of disabling
it, so you can still push it but nothing happens? Or, in the handler, do
nothing, depending on the state of a flag?

Or you could substitute the button with a picture of the button.

Andrew
Oct 1 '08 #13
Okay so I ended up leaving the .Enabled property of the button set to
true. There were conditions for which I wanted this button to be
disabled, so I just added those conditions to the Click event for the
button. The code in the click event only executes when I want it to.

Also, I'm using .FlatStyle = Flat for my buttons. When the button is
available I had the .FlatAppearance.MouseDownBackColor
and .FlatAppearance.MouseOverBackColor set to something different that
the actual backcolor of the button. So when it's not available i
simply changed those two values to be equal to the button BackColor.

So unless certain conditions are met, no code executes on the click
and there is no visual feedback to the user that the button has been
clicked.
Oct 1 '08 #14
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:3B**********************************@microsof t.com...
Bill,

Nobody prevents somebody to create his own controls.

However as you say: "I have made this with Visual Studio, then a kind of
standard behaviour is expected". Especially as you don't make it for kids.

It is for me as placing an engine from a Fiat Panda in a Ferrari and then
sell it as a standard Ferrari.
ummm... Huh? Panda? They still make Fiat's? Ferrari? Not sure what that's
supposed to mean, but... what ever floats your boat. I happen to drive a 4x4
truck.
jmo

Cor

"Bill McCarthy" <Bi**@localhost.comschreef in bericht
news:e%****************@TK2MSFTNGP06.phx.gbl...
>>
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.comwrote in message
news:e4*************@TK2MSFTNGP06.phx.gbl...
>>>
Now, if you insist on "breaking the rules", no one can stop you. You
should be able to place those buttons inside of a container control and
disable the container, instead of the button.

Did you actually fire up Visual Studio and test that ? I would be
expecting that not to work, rather the enabled status would cascade down
to child controls.
Isn't that beautiful... even more broken code and migration headaches. I
suppose people think that's just "wonderful", eh? geez... even the arrow
keys work differently when trying to position controls. "Glitter" instead of
functionality. Perfect.

btw, the Visual Studio I use daily "requires skill and knowledge"... isn't
that the favorite "I'm better than you" statement?. Some of that "knowledge"
says controls don't change their appearance simply because their container
is disabled. They never have. But, it's a "brave new world", right? Where
everything changes within a moments notice (or the next Windows Update)

--
Ken Halter
Part time groupie
Oct 1 '08 #15

"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.comwrote in message
news:eZ**************@TK2MSFTNGP04.phx.gbl...
>>
"Bill McCarthy" <Bi**@localhost.comschreef in bericht
news:e%****************@TK2MSFTNGP06.phx.gbl...
>>>
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.comwrote in message
news:e4*************@TK2MSFTNGP06.phx.gbl...

Now, if you insist on "breaking the rules", no one can stop you. You
should be able to place those buttons inside of a container control and
disable the container, instead of the button.

Did you actually fire up Visual Studio and test that ? I would be
expecting that not to work, rather the enabled status would cascade down
to child controls.

Isn't that beautiful... even more broken code and migration headaches. I
suppose people think that's just "wonderful", eh? geez... even the arrow
keys work differently when trying to position controls. "Glitter" instead
of functionality. Perfect.

btw, the Visual Studio I use daily "requires skill and knowledge"... isn't
that the favorite "I'm better than you" statement?. Some of that
"knowledge" says controls don't change their appearance simply because
their container is disabled. They never have. But, it's a "brave new
world", right? Where everything changes within a moments notice (or the
next Windows Update)
Uhm, breathe Ken, breathe.
I take it from that hysteria posted above the answer to my question was no
you hadn't actually fired up Visual Studio and tested it.

As to your other comments, I guess you are trying to say the bad behavior of
VB6 not rendering buttons as disabled if the container is disabled is
somehow good because that's all you know ? In VB6 if you write code such as
Command1.Enabled = Not Command1.Enabled, no matter what your control won't
get rendered differently at runtime if the container is disabled. This goes
against the basic programming principles of the object defining it's own
appearance and windows guidelines. And what's even worse is if you set
Enabled to false at design time, then the button will be displayed as
disabled. But should you toggle that, you cannot get it back to that state
without first enabling the container. That's right, in VB6 with the
container disabled, you can go from button drawing as disabled to normal but
never back. Just because that's the behavior you know, does not make it
right. It's great .NET addressed those kind of issues properly.





Oct 1 '08 #16
Bill,

Here we normally don't behave as in the VB general discussions newsgroup.

We simply ignore people who throw mud.

As Sutur is consequently doing the same too me, as is done in the VB
general discussion newsgroup too you by some people, I would have expected
from you other behaviour.

Cor

"Bill McCarthy" <Bi**@localhost.comschreef in bericht
news:eG**************@TK2MSFTNGP02.phx.gbl...
Hi David,

The colors disabled controls change to is controlled by the sytem's color
schemes. Users can change these based on their monitor and/or visual
impairment they may have. There's also a standard set of schemes such as
high visibility etc. So if you do your own custom thing, you're fighting
against the system and the user ;)

That said, I know there are times you want to display information to the
user, but not allow interaction. I don't think a button is the right
choice there. One simple option might be to hide a button and instead
show a label or show a label over the button is the button is disabled.

Whatever approach you take, it really needs to be tested at a minim
against all the standard windows color schemes and themes (turn themes
both on and off). These days I also try to run the apps with a screen
reader to make sure there's no accessibility issues.

"SurturZ" <su*****@newsgroup.nospamwrote in message
news:E9**********************************@microsof t.com...
>>I for one hate this standard. It is very common to want a version of a
data
entry form that is "read only".

Setting .Enabled=False would be the easiest way to do it, except that in
many cases the controls become unreadable. It is not very clear how
Windows
decides what colours to use for these disabled controls.

It's okay that the colours change for disabled controls, what irks me is
the
lack of control over what the colours change *to*.

I don't think Cor Ligthert's comment was useful at all. If you can't post
something polite and helpful, don't post at all.

--
David Streeter
Synchrotech Software
Sydney Australia
"Bill McCarthy" wrote:
>>>
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.comwrote in message
news:e4*************@TK2MSFTNGP06.phx.gbl...

Now, if you insist on "breaking the rules", no one can stop you. You
should be able to place those buttons inside of a container control
and
disable the container, instead of the button.

Did you actually fire up Visual Studio and test that ? I would be
expecting
that not to work, rather the enabled status would cascade down to child
controls.

Oct 1 '08 #17
I was actually thinking of textboxes rather than buttons. It seems silly to
me to re-write a whole new "read only" version of the form using labels
rather than simply setting .Enabled = False on all the textboxes. For
textboxes, .ReadOnly works I guess, but not all data entry controls have
..ReadOnly (comboboxes don't for example).

In any case, I am not sure which system color in the Windows control panel
is used for disabled buttons/textboxes. The control.ForeColor property does
not change when you disable a control (even though the ForeColor is obviously
changed to grey). There is a SystemColors.InactiveCaptionText but no
SystemColors.InactiveControlText

If anyone can tell me how to change the "disabled text" of a control to say
pink instead of grey, I would be most appreciative.
--
David Streeter
Synchrotech Software
Sydney Australia
"Bill McCarthy" wrote:
Hi David,

The colors disabled controls change to is controlled by the sytem's color
schemes. Users can change these based on their monitor and/or visual
impairment they may have. There's also a standard set of schemes such as
high visibility etc. So if you do your own custom thing, you're fighting
against the system and the user ;)

That said, I know there are times you want to display information to the
user, but not allow interaction. I don't think a button is the right choice
there. One simple option might be to hide a button and instead show a label
or show a label over the button is the button is disabled.

Whatever approach you take, it really needs to be tested at a minim against
all the standard windows color schemes and themes (turn themes both on and
off). These days I also try to run the apps with a screen reader to make
sure there's no accessibility issues.

"SurturZ" <su*****@newsgroup.nospamwrote in message
news:E9**********************************@microsof t.com...
I for one hate this standard. It is very common to want a version of a data
entry form that is "read only".

Setting .Enabled=False would be the easiest way to do it, except that in
many cases the controls become unreadable. It is not very clear how
Windows
decides what colours to use for these disabled controls.

It's okay that the colours change for disabled controls, what irks me is
the
lack of control over what the colours change *to*.

I don't think Cor Ligthert's comment was useful at all. If you can't post
something polite and helpful, don't post at all.

--
David Streeter
Synchrotech Software
Sydney Australia
"Bill McCarthy" wrote:
>
"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.comwrote in message
news:e4*************@TK2MSFTNGP06.phx.gbl...

Now, if you insist on "breaking the rules", no one can stop you. You
should be able to place those buttons inside of a container control and
disable the container, instead of the button.

Did you actually fire up Visual Studio and test that ? I would be
expecting
that not to work, rather the enabled status would cascade down to child
controls.


Oct 2 '08 #18

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

Similar topics

3
by: Steve Le Monnier | last post by:
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...
0
by: Tim | last post by:
Hi There I am trying to override the forecolor of a radio button when the flat style is set to system. I am using a manifest file. If you set the name to the same name as your exe with .manifest...
11
by: Dot net work | last post by:
Hello. I've read many posts about disabling submit buttons, but I can't get these answers to solve my problem. I have a server side asp.net button, and under the button I have code behind...
1
by: tshad | last post by:
I want to be able to change the color of the text of a button after it is pressed. The first part of the event is: sub submitQuestion_click(Sender as Object, e as EventArgs)...
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: dba123 | last post by:
How do I take my GridView and create a function that will update -all- checkbox values for the submit button's OnClick event? I have posted both my SQLDataSource and my GridView below: ...
0
by: Jeff | last post by:
in VB.net with Visual Studio 2005 is there a way to alter the forecolor on a listbox or other asp control when the control is disabled? ....easy to do for the enabled colors, but I can't find...
3
by: =?Utf-8?B?c2xlbWVu?= | last post by:
Hi, My GridView is bound to a DataTable and the GridView properties are set as follows: AutoGenerateColumns="true" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" The Edit and...
4
by: Allan Ebdrup | last post by:
When I set the forecolor of a linkbutton to red after setting enabled to false, the linkbutton stays grey? How do I change the appearance of a disabled linkbutton? Kind Regards, Allan Ebdrup
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.