This is a migrated thread and some comments may be shown as answers.

Style for Disabled Button with Image

5 Answers 1114 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 18 Oct 2011, 06:21 PM
The default style does not gray out the image on a button that is disabled.

But there are other themes that do gray out the image (such as Desert, Breeze).

I'm making a copy of the default style and making small adjustments.  How can I make my custom theme use a gray image for a button that is disabled?

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Oct 2011, 10:07 AM
Hi Brian,

To achieve the desired look, you should set the Enabled property of the ButtonElement, instead of the Enabled property of the button control. Here is a code sample:
radButton1.ButtonElement.Enabled = false;

I hope that the provided information addresses your question. Should you have any other questions, do not hesitate to contact us.
 
Kind regards,
Stefan
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Brian
Top achievements
Rank 1
answered on 22 Oct 2011, 12:52 AM
I tried setting that element but it didn't seem to work either.

Also, that doesn't make sense, because with different styles, the image is gray and I didn't have to set the element's disabled property.

It certainly seems to be something in the visual style that is causing the image to go gray.
0
Accepted
Stefan
Telerik team
answered on 27 Oct 2011, 08:47 AM
Hello Brian,

Thank you for writing back with your concerns.

In order to gray-out the image of the button, the UseDefaultDisabledPaint property should be set to true. This setting is introduced to the ButtonElement by default and this is why I recommended disabling the ButtonElement. However, it is possible that this property is modified on your end and the provided code is not working. Please make sure that the property has the correct value set - true. Here are two code snippets demonstrating how to achieve the desired functionality:
radButton1.Enabled = false;
radButton1.RootElement.UseDefaultDisabledPaint = true;
 
//or
radButton1.ButtonElement.Enabled = false;
radButton1.ButtonElement.UseDefaultDisabledPaint = true;

I hope that you find this helpful. Let me know if you have any other questions.
 
All the best,
Stefan
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Eric
Top achievements
Rank 1
answered on 25 Feb 2012, 02:37 AM
First thank you support for this as it fixed my problem as well.  I also want to point out that for me I was having issues with only setting the button to disabled.  It wasn't getting updated until I did both the button and the RootElement.  

I would submit that having to do something like this is very un-RAD (opposite of rapid).  This is something that .net has just done for years.  Given you're implementing their button class, I would expect that the button.Enabled is directly linked to button.RootElement.Enabled.  Also, I would expect that the setting 
btnSettings.RootElement.UseDefaultDisabledPaint = true;

(help, stuck in formatting box and can't get out)

... would just be default for all styles etc.  That said, even though I did update our style (.tssp) I still
have to manually call the line above.
0
Stefan
Telerik team
answered on 29 Feb 2012, 01:50 PM
Hello Eric,

I am glad to hear that this thread helped you.

In regards to your suggestion, the UseDefaultDisabledPaint property's default value is true, so simply disabling the button will gray out the whole button. However, the property setting can be introduced also by the theme (as with the ControlDefault theme for example), in cases where the disabled state of the button is themed (you might want different appearance when the button is disabled than the default one). So, if you have set this property via theme, and then you want to change its value, you can do that via code.

I hope you find this information useful. Let me know if I can be of further assistance.

Greetings,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
Themes and Visual Style Builder
Asked by
Brian
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Brian
Top achievements
Rank 1
Eric
Top achievements
Rank 1
Share this question
or