16 Answers, 1 is accepted
0
Hi eriksurya,
The background of the button is defined by the fill primitive. To change its properties, open the Edit UI Elements through the smart tag. It will open tree with the button control structure, select the FillPrimitive and configure it as you like. You can also use the Visual Style Builder to define button themes and save them in XML format.
Best,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The background of the button is defined by the fill primitive. To change its properties, open the Edit UI Elements through the smart tag. It will open tree with the button control structure, select the FillPrimitive and configure it as you like. You can also use the Visual Style Builder to define button themes and save them in XML format.
Best,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Erik
Top achievements
Rank 1
answered on 21 Aug 2007, 03:38 PM
Hi,
Can i change the color in running time? Using code especially. Thanks
Can i change the color in running time? Using code especially. Thanks
0
Hello eriksurya,
Thank you for contacting us with this question.
You can change the back color of the RadButton at runtime using the following line of code:
Please keep in mind that by default, the RadButton's fill mode is gradient, so if you need to have a solid background, you also need to add this next line of code. Using the GradientStyle property you can change the type of gradient (Gel, Glass, etc.)
You have to use the BackColor2, BackColor3 and BackColor4 properties for the colors to be used for the gradient of the FillPrimitive. You can also modify the number of colors in the gradient using the NumberOfColors property of the FillPrimitive.
Keep in mind, applying a BackColor like that will override any setting to the BackColor coming from a theme.
Thank you for taking the time to write again. Please let me know if you have any additional questions.
Greetings,
Kiril
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for contacting us with this question.
You can change the back color of the RadButton at runtime using the following line of code:
((FillPrimitive)radButton1.ButtonElement.GetChildrenByType(typeof(FillPrimitive))[0]).BackColor = Color.Blue; |
Please keep in mind that by default, the RadButton's fill mode is gradient, so if you need to have a solid background, you also need to add this next line of code. Using the GradientStyle property you can change the type of gradient (Gel, Glass, etc.)
((FillPrimitive)radButton1.ButtonElement.GetChildrenByType(typeof(FillPrimitive))[0]).GradientStyle = Telerik.WinControls.GradientStyles.Solid; |
You have to use the BackColor2, BackColor3 and BackColor4 properties for the colors to be used for the gradient of the FillPrimitive. You can also modify the number of colors in the gradient using the NumberOfColors property of the FillPrimitive.
Keep in mind, applying a BackColor like that will override any setting to the BackColor coming from a theme.
Thank you for taking the time to write again. Please let me know if you have any additional questions.
Greetings,
Kiril
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Erik
Top achievements
Rank 1
answered on 24 Aug 2007, 08:58 AM
Hi,
Thanks for your reply. Can telerik make this function easier, I mean the API? So we just lets say button1. backcolor1, button2.backcolor2, etc..
thanks
Thanks for your reply. Can telerik make this function easier, I mean the API? So we just lets say button1. backcolor1, button2.backcolor2, etc..
thanks
0
Hello eriksurya,
Thank you for your email. This is a request we get quite a bit. Simplifying the structure of our controls is important for a variety of reasons, but has to also be balanced with the flexibility the control has to offer.
The decision to have the BackColors down at the level of the FillPrimitive was made for a variety of reasons:
Kind regards,
Kiril
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for your email. This is a request we get quite a bit. Simplifying the structure of our controls is important for a variety of reasons, but has to also be balanced with the flexibility the control has to offer.
The decision to have the BackColors down at the level of the FillPrimitive was made for a variety of reasons:
- The BackColor property, together with other design properties is meant to be set using the Visual Style Builder, using a theme. It's not meant to be modified at runtime with user code.
- Having the BackColor property at the top-level of the Control would make the RadButton less customizable. For example, the user would have a single BackColor for the whole control, and will not be able to define a different BackColor for the text for example.
- Furthermore, the standard Microsoft button does not allow changing of the back color, and does not have such a property at all.
Kind regards,
Kiril
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Bryan Brannon
Top achievements
Rank 2
answered on 15 Nov 2007, 04:34 AM
Can you provide the VB.NET code to change the background color of a button using the FillPrimitive example above?
0
Hi Bryan Brannon,
Thank you for writing.
The FillPrimitive has a number of modes of operation. They are controlled by the GradientStyle and NumberOfColors properties. The FillPrimitive can use up to 4 colors (set using the BackColor, BackColor2, BackColor3 and BackColor4 properties) to be combined according to the GradientStyle and NumberOfColors properties to produce the final look.
The code below uses the simplest scenario, with a solid fill with a single color set to red:
I hope that helps. If you have any additional questions, please contact us again.
Kind regards,
Kiril
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for writing.
The FillPrimitive has a number of modes of operation. They are controlled by the GradientStyle and NumberOfColors properties. The FillPrimitive can use up to 4 colors (set using the BackColor, BackColor2, BackColor3 and BackColor4 properties) to be combined according to the GradientStyle and NumberOfColors properties to produce the final look.
The code below uses the simplest scenario, with a solid fill with a single color set to red:
DirectCast((Me.radButton1.GetChildAt(0).GetChildAt(0)), Telerik.WinControls.Primitives.FillPrimitive).GradientStyle = Telerik.WinControls.GradientStyles.Solid |
DirectCast((Me.radButton1.GetChildAt(0).GetChildAt(0)), Telerik.WinControls.Primitives.FillPrimitive).NumberOfColors = 1 |
DirectCast((Me.radButton1.GetChildAt(0).GetChildAt(0)), Telerik.WinControls.Primitives.FillPrimitive).BackColor = System.Drawing.Color.FromArgb(CInt(CByte((240))), CInt(CByte((19))), CInt(CByte((44)))) |
I hope that helps. If you have any additional questions, please contact us again.
Kind regards,
Kiril
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Ryan
Top achievements
Rank 1
answered on 31 Jul 2008, 07:08 PM
The example of the DirectCast of the radbutton1 works...but when I tried it with a radtxtbox I got this error. Can you tell me why?
System.InvalidCastException was unhandled
Message="Unable to cast object of type 'Telerik.WinControls.UI.RadTextBoxItem' to type 'Telerik.WinControls.Primitives.FillPrimitive'."
Source="PersonForm_072708"
StackTrace:
at PersonForm_072708.frmPerson.frmPerson_Load(Object sender, EventArgs e) in C:\projects\PersonForm_072708\PersonForm_072708\PersonForm_072708\frmPerson.vb:line 190
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at Telerik.WinControls.UI.ShapedForm.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at Telerik.WinControls.UI.ShapedForm.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()
at PersonForm_072708.Form1.Button1_Click(Object sender, EventArgs e) in C:\projects\PersonForm_072708\PersonForm_072708\PersonForm_072708\Form1.vb:line 11
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.PerformClick()
at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at PersonForm_072708.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
System.InvalidCastException was unhandled
Message="Unable to cast object of type 'Telerik.WinControls.UI.RadTextBoxItem' to type 'Telerik.WinControls.Primitives.FillPrimitive'."
Source="PersonForm_072708"
StackTrace:
at PersonForm_072708.frmPerson.frmPerson_Load(Object sender, EventArgs e) in C:\projects\PersonForm_072708\PersonForm_072708\PersonForm_072708\frmPerson.vb:line 190
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at Telerik.WinControls.UI.ShapedForm.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at Telerik.WinControls.UI.ShapedForm.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()
at PersonForm_072708.Form1.Button1_Click(Object sender, EventArgs e) in C:\projects\PersonForm_072708\PersonForm_072708\PersonForm_072708\Form1.vb:line 11
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.PerformClick()
at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at PersonForm_072708.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
0
Hello Ryan,
This is a normal behavior because the RadButton and RadTextBox are different controls with different elements hierarchically - see the attached screenshots.
You should use the Telerik SPY controls utility to inspect the elements hierarchy .
Hope this will clear the situation.
Greetings,
Peter
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
This is a normal behavior because the RadButton and RadTextBox are different controls with different elements hierarchically - see the attached screenshots.
You should use the Telerik SPY controls utility to inspect the elements hierarchy .
Hope this will clear the situation.
Greetings,
Peter
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
John Davis
Top achievements
Rank 2
answered on 18 Feb 2011, 11:17 PM
I am using a radform and radbuttons. It is important to change button colors. (If it is too hard, is there a different contral that would work better?)
The code you provided works, but it changes only the top part, I guess because there is a gradient. (see the second button)
How can I:
1) Capture the button default background color definition (shown in the first button).
2) In code, reset the button to this default background color definition, after it has been changed.
2) In code, set the button background color so it looks like the third button (top and bottum have a new color).
John
0
Hello John,
Peter
the Telerik team
Thank you for the writing.
You should modify the BackColor and BackColor4 properties to change top and bottom colors - please refer to the attached project.
In addition, you can create your own theme using our Visual Style Builder.
I hope this helps.
Peter
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Chuck
Top achievements
Rank 1
answered on 12 May 2011, 04:25 PM
i have created a theme that has modifed the radbutton and it work correctly.
the button is simulating a generic hardware device used by our comapany.
the theme is used 90% of the time as is, but somtimes i must change the color (fill)
using the radbutton tasks to chage the fill color works for the idle state, but not for the mouse over, mousedown states.
how can i edit those settings at runtime? using c# winforms
thnaks
(CNIN)
the button is simulating a generic hardware device used by our comapany.
the theme is used 90% of the time as is, but somtimes i must change the color (fill)
using the radbutton tasks to chage the fill color works for the idle state, but not for the mouse over, mousedown states.
how can i edit those settings at runtime? using c# winforms
thnaks
(CNIN)
0
Hi Robert,
You should modify the background color on MouseOver, MouseDown and MouseLeave events. I attached a sample project which demonstrates the described approach. Please take a look.
Should you have any additional questions, do not hesitate to ask.
Kind regards, Peter
the Telerik team
You should modify the background color on MouseOver, MouseDown and MouseLeave events. I attached a sample project which demonstrates the described approach. Please take a look.
Should you have any additional questions, do not hesitate to ask.
Kind regards, Peter
the Telerik team
0
Carol
Top achievements
Rank 1
answered on 25 Jul 2013, 09:22 PM
I placed a RadButton on my RadForm and changed the FillPrimitive back color settings to what I want. I also changed the shape to the rounded rectangle and the radius to 15, so the button looks like it is rounded. However, the corners still show the same color as the rounded part of the button. I wish to set them to transparent so they are not visible, so the button actually looks rounded at runtime, and not square with a rounded line drawn inside of it. How do I do this. Every other backcolor property I found, anywhere, is set to transparent, but the corners still have color. What am I missing?
0
Carol
Top achievements
Rank 1
answered on 25 Jul 2013, 10:29 PM
Nevermind, I figured it out. Discovered hidden code I had left behind where I was setting a theme at runtime.
0
Hello Carol,
I am happy that you found a solution for this.
Please note that Edit UI Elements through the smart tag will serialize a local values and these values will override the theme settings.
You can write back and open a new support ticket anytime you have further questions or need assistance.
Regards, Peter
Telerik
I am happy that you found a solution for this.
Please note that Edit UI Elements through the smart tag will serialize a local values and these values will override the theme settings.
You can write back and open a new support ticket anytime you have further questions or need assistance.
Regards, Peter
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>