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

Change BackColor for RabButtonElement in RadToolStrip Control

3 Answers 237 Views
Toolstrip (obsolete as of Q3 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dian
Top achievements
Rank 1
Dian asked on 13 Oct 2010, 02:39 AM
I have a search button added in RadToolStrip Control, I'd like to change its backcolor after user clicked it, but it doesn't work.

 

 

 

Me.RadBuSearch.Focus()

 

 

 

Me.RadBuSearch.BackColor = Color.Red

Can you help?

Thanks.

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 13 Oct 2010, 04:51 AM
Hello Dian,

The normal backcolor of the button is given by a FillPrimitive which is using a Gradient, so that's the reason why you cannot just change the background color of the button.
To change this, you have to get the FillPrimitive and using the GradientStyle property you can change the type of gradient (Gel, Glass, etc.), and the color to use.
((FillPrimitive)button.ButtonElement.GetChildrenByType(typeof(FillPrimitive))[0]).BackColor = Color.Red;
((FillPrimitive)button.ButtonElement.GetChildrenByType(typeof(FillPrimitive))[0]).GradientStyle = Telerik.WinControls.GradientStyles.Solid;

Keep in mind, applying a BackColor like that will override any setting to the BackColor coming from a theme, and also it will cause the OnHover state to be less visible.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
PAGCA
Top achievements
Rank 1
answered on 19 Dec 2011, 11:52 PM
Could you show us that code in VB please? For a Q3 button.
0
Stefan
Telerik team
answered on 22 Dec 2011, 06:13 PM
Hi Don,

Thank you for writing.

Since Q3 2011, RadToolStrip control is no longer part of our suite, since it has been replaced by RadCommandBar. However, I assume that you need the code in VB to use it for RadButtonElements in other places, so here is it:
Dim button As New RadButtonElement()
button.ButtonFillElement.BackColor = Color.Red
button.ButtonFillElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid

If needed in future, feel free to use our free online C# to VB and vice versa converter at: http://converter.telerik.com/.

I hope that you find this information useful. Should you have any additional questions, do not hesitate to write back.
 
Greetings,
Stefan
the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
Toolstrip (obsolete as of Q3 2010)
Asked by
Dian
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
PAGCA
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or