Change BackColor for RabButtonElement in RadToolStrip Control

4 posts, 1 answers
  1. Dian
    Dian avatar
    16 posts
    Member since:
    Oct 2010

    Posted 12 Oct 2010 Link to this post

    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.BackColor = Color.Red

    Can you help?



  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 12 Oct 2010 Link to this post

    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
  3. DevCraft R3 2016 release webinar banner
  4. Don
    Don avatar
    7 posts
    Member since:
    Sep 2011

    Posted 19 Dec 2011 Link to this post

    Could you show us that code in VB please? For a Q3 button.
  5. Stefan
    Stefan avatar
    2891 posts

    Posted 22 Dec 2011 Link to this post

    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:

    I hope that you find this information useful. Should you have any additional questions, do not hesitate to write back.
    the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top