Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Toolstrip (obsolete as of Q3 2010) > Change BackColor for RabButtonElement in RadToolStrip Control

Answered Change BackColor for RabButtonElement in RadToolStrip Control

Feed from this thread
  • Dian avatar

    Posted on Oct 12, 2010 (permalink)

    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.

     

    Reply

  • Posted on Oct 12, 2010 (permalink)

    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

    Reply

  • Don avatar

    Posted on Dec 19, 2011 (permalink)

    Could you show us that code in VB please? For a Q3 button.

    Reply

  • Stefan Stefan admin's avatar

    Posted on Dec 22, 2011 (permalink)

    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Toolstrip (obsolete as of Q3 2010) > Change BackColor for RabButtonElement in RadToolStrip Control
Related resources for "Change BackColor for RabButtonElement in RadToolStrip Control"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]