Set Dynamically created RadGroupBox back ground color

4 posts, 0 answers
  1. Alquin Cook
    Alquin Cook avatar
    4 posts
    Member since:
    Dec 2009

    Posted 24 Aug 2010 Link to this post

    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
  2. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 26 Aug 2010 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Alquin Cook
    Alquin Cook avatar
    4 posts
    Member since:
    Dec 2009

    Posted 26 Aug 2010 Link to this post

    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.
  5. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 01 Sep 2010 Link to this post

    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
Back to Top