radbutton back color won't change anymore

6 posts, 1 answers
  1. John
    John avatar
    60 posts
    Member since:
    Nov 2006

    Posted 19 Jan 2013 Link to this post

    I was using the 2012 q2 release and changing back color of my buttons on the fly with

    ((FillPrimitive)radButton1.ButtonElement.GetChildrenByType(typeof(FillPrimitive))[0]).BackColor = Color.Blue; 


    i upgraded to 2012 q3.  i also tried the latest dev build of that version.  Now the above code has no affect.  the buttons stay themed as officeblue.
    how do i fix this?  i want to be able to change them on the fly like i used to be able to.  there are a few buttons in my app that the user can set the color to on the fly and this broke.

    thanks.
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 21 Jan 2013 Link to this post

    Hello John,

    Thank you for writing.

    This code works just fine on my end. Could you please let me know what is the behavior that you experience?

    An alternative of this code is:
    radButton1.ButtonElement.ButtonFillElement.BackColor = Color.Red;

    Also, you might want to check the value of the FillPrimitive.GradientStyle property, if you want a solid color.
     

    All the best,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. John
    John avatar
    60 posts
    Member since:
    Nov 2006

    Posted 22 Jan 2013 Link to this post

    Hi Stefan, you have to apply a theme first to see the problem.  using a global app theme, i was able to change the button back color in previous versions of telerik controls.  q3 i am not able to.  i was going to attach an example but it won't take zip files.  to reproduce it, just add a theme

    something like this

     private void Form1_Load(object sender, EventArgs e)
            {
                ThemeResolutionService.LoadPackageResource("WindowsFormsApplication1.Office2010Blue.tssp");
                ThemeResolutionService.ApplicationThemeName = "Office2010Blue";

                radButton1.ButtonElement.ButtonFillElement.GradientStyle = GradientStyles.Solid;
                
                radButton1.ButtonElement.ButtonFillElement.BackColor = Color.Red;
            }
  5. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 25 Jan 2013 Link to this post

    Hi John,

    Thank you for writing.

    The office themes use RadImageShape to style the button's border and in order to allow its fill to be visible, you have to remove this shape:
    radButton1.ButtonElement.BorderElement.BackgroundShape = null;
    radButton1.ButtonElement.ButtonFillElement.GradientStyle = GradientStyles.Solid;
    radButton1.ButtonElement.ButtonFillElement.BackColor = Color.Red;

    I hope this helps.
     
    Kind regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  6. John
    John avatar
    60 posts
    Member since:
    Nov 2006

    Posted 04 Feb 2013 Link to this post

    Thanks, that got me almost all the way.  i ended up having to set backcolor2,3 and 4 also to the color i wanted to make it solid

  7. Plamen
    Admin
    Plamen avatar
    132 posts

    Posted 07 Feb 2013 Link to this post

    Hi John,

    Thank you for this update. We are glad to hear that you are happy with this solution. You can control the background by using also GradientStyle and NumberOfColors properties.

    Do not hesitate to contact us If you have further questions.

    Regards,
    Plamen
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Back to Top
UI for WinForms is Visual Studio 2017 Ready