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

Set Dynamically created RadGroupBox back ground color

3 Answers 91 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Alquin Cook
Top achievements
Rank 1
Alquin Cook asked on 24 Aug 2010, 03:51 PM
Hello,

I am currently using RadControls for WinForms Q1 2010 and I'm trying to change the back ground color to white on a dynamically added RadGroupBox, but it isn't working. I've tried several different approaches but all I get is a gradient looking gray background.

Public Class MyRadGroupBox
    Inherits Telerik.WinControls.UI.RadGroupBox
  
 '========================================================================================================================
    ' This is the constructor for this class
    '========================================================================================================================
    Public Sub New()
  
        Me.HeaderMargin = New System.Windows.Forms.Padding(0)
        Me.HeaderText = ""
        Me.Location = New System.Drawing.Point(3, 2)
        Me.Name = "myRadGroupBox"
        Me.Padding = New System.Windows.Forms.Padding(1)
        Me.Margin = New System.Windows.Forms.Padding(1)
        Me.Size = New System.Drawing.Size(500, 386)
        Me.RootElement.Padding = New System.Windows.Forms.Padding(1)
        'Me.RootElement.BackColor = System.Drawing.Color.White         
        'Me.BackColor = System.Drawing.Color.White 
        'Me.GroupBoxElement.BackColor = System.Drawing.Color.White 
  
        DirectCast(Me.GroupBoxElement.Content.Children(0), FillPrimitive).BackColor = System.Drawing.Color.White
  
    End Sub
  
  
End Class

3 Answers, 1 is accepted

Sort by
0
Boryana
Telerik team
answered on 26 Aug 2010, 07:47 PM
Hello Alquin Cook,

Thank you for contacting us.

In case you would like to keep the styling mechanism of RadGroupBox in your customized control, you might be interested in this Knowledge Base article.

As to your specific question, you can set the background color of your modified RadGrouopBox through the following piece of code:
Dim fill As FillPrimitive = Me.MyRadGroupBox1.GroupBoxElement.Content.Fill
fill.NumberOfColors = 4
fill.BackColor = Color.Orange
fill.BackColor2 = Color.Orange
fill.BackColor3 = Color.PeachPuff
fill.BackColor4 = Color.PeachPuff
fill.GradientStyle = Telerik.WinControls.GradientStyles.Linear
fill.GradientPercentage = 0.2
fill.GradientPercentage2 = 0.8

I hope you will find my answer helpful. Let me know if I can assist you further.

Regards,
Boryana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alquin Cook
Top achievements
Rank 1
answered on 26 Aug 2010, 08:19 PM
Boryana,

I've tried the code snippet you suggested, but I get this error: 'Telerik.WinControls.UI.GroupBoxVisualElement.fill' is not accessible in this context because it is 'Protected'.

I've even overidden the property ThemeClassName and applied a theme, but the controls back color hasn't changed.
0
Nikolay
Telerik team
answered on 01 Sep 2010, 01:17 PM
Hello Alquin Cook,

Thank you for getting back to us.

I am not sure why you are experiencing the described compile error. I am attaching a sample project which implements the approach demonstrated in this article and which also includes the code snippet provided by my colleague Boryana. I hope that it will help you.

If you have additional questions, feel free to contact us.

Sincerely yours,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Themes and Visual Style Builder
Asked by
Alquin Cook
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Alquin Cook
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or