Windows Develop Bookmark and Share   
 index > Windows Forms General > Disabled Button Controls
 

Disabled Button Controls

When you change the BackColor of a Form (also happens on a UserControl), a Button control with its Enabled property set to False loses part of its Disabled look. The text appears inabout the same color as another button that is enabled. I don't know if this holds true for all colors, but it does for all the ones I tried.

Any thoughts on how I can prevent this? (other than don't change the BackColor of the form.)

Tony

tkerns  Thursday, July 12, 2007 7:10 PM
Yes, I see this too. I see some convoluted code in ButtonBaseAdapter.ColorCode.Calculate() that tries to calculate a color that contrasts with the container color. That's a bit silly, it probably ought to work with the BackColor of the button itself. Although the active Visual Style might have transparencies. Anyhoo, if you pick a darkish BackColor for your container, you'll end up with something darker still: Black. Only if the BackColor has a brightness >= 0.5 will you get a grayish text color.

I don't see a good workaround for this, nothing you can easily override. Other than changing the button style. You might want to report this at Product Feedback.
nobugz  Thursday, July 12, 2007 8:21 PM
Yes, I see this too. I see some convoluted code in ButtonBaseAdapter.ColorCode.Calculate() that tries to calculate a color that contrasts with the container color. That's a bit silly, it probably ought to work with the BackColor of the button itself. Although the active Visual Style might have transparencies. Anyhoo, if you pick a darkish BackColor for your container, you'll end up with something darker still: Black. Only if the BackColor has a brightness >= 0.5 will you get a grayish text color.

I don't see a good workaround for this, nothing you can easily override. Other than changing the button style. You might want to report this at Product Feedback.
nobugz  Thursday, July 12, 2007 8:21 PM

Thanks for the response. I'll look for a workaround.

Tony

tkerns  Friday, July 13, 2007 3:53 PM

You can use google to search for other answers

Custom Search

More Threads

• "PropertyGrid" problem
• can't add item to listbox
• Sorting disable in datagridview datetime column after binding with source.
• FolderBrowserDialog hangs debugger on some selections
• Movable and Resizable Panel
• heigth of comboboxes controls when designing a form
• OpenForms FormCollection Item
• Control.InvokeOnClick and Validation of a Form
• Caption bar for Datagridviewcolumn?
• TreeView Owner Draw problem