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

radbutton back color won't change anymore

5 Answers 284 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 20 Jan 2013, 01:19 AM
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.

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 21 Jan 2013, 09:31 AM
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.
0
John
Top achievements
Rank 1
answered on 22 Jan 2013, 07:36 PM
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;
        }
0
Accepted
Stefan
Telerik team
answered on 25 Jan 2013, 11:53 AM
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.
0
John
Top achievements
Rank 1
answered on 04 Feb 2013, 02:48 PM
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

0
Plamen
Telerik team
answered on 07 Feb 2013, 03:54 PM
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.
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
John
Top achievements
Rank 1
Answers by
Stefan
Telerik team
John
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or