Theming RadGroupBox

5 posts, 1 answers
  1. Jason
    Jason avatar
    47 posts
    Member since:
    Jan 2013

    Posted 07 Mar 2014 Link to this post

    The RadGroupBox has 2 different style - Office & Standard. 

    Is it possible to define 2 distinct themes for each mode of the RadGroupBox, or do we have to define a custom control? For instance, I want to have a different background colour for the header in each mode

    Cheers
  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 12 Mar 2014 Link to this post

    Hello Jason,

    Thank you for contacting Telerik support.

    You cannot define a different styling for the GroupBoxStyle modes within a single theme using Visual Style Builder - each theme can hold a single style for a control. For this case you can change the theme or any styles in code after you have changed the GroupBoxStyle. For example you can change the background color when you are switching the mode like this:
    private void radButton1_Click(object sender, EventArgs e)
    {
        if (radGroupBox1.GroupBoxStyle == Telerik.WinControls.UI.RadGroupBoxStyle.Standard)
        {
            radGroupBox1.GroupBoxStyle = Telerik.WinControls.UI.RadGroupBoxStyle.Office;
            this.radGroupBox1.GroupBoxElement.Header.Fill.BackColor = Color.Aqua;      
        }
        else
        {
            radGroupBox1.GroupBoxStyle = Telerik.WinControls.UI.RadGroupBoxStyle.Standard;
            this.radGroupBox1.GroupBoxElement.Header.Fill.BackColor = Color.Gray;
        }
    }

    If you have any questions, please do not hesitate to contact us.

    Regards,
    Dimitar
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jason
    Jason avatar
    47 posts
    Member since:
    Jan 2013

    Posted 27 Mar 2014 in reply to Dimitar Link to this post

    OK, I've managed to come up with something that does the job, using a custom control inherited from the RadGroupBox

    However, is there a way to hook into the action of when the groupboxstyle changes, so I make the relevant changes to the appearance?

    Cheers
  5. Answer
    Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 28 Mar 2014 Link to this post

    Hello Jason,

    Thank you for writing.

    You can use the RadPropertyChanged event of the header to determine that GroupBoxStyle property is changed: 
    void Header_RadPropertyChanged(object sender, Telerik.WinControls.RadPropertyChangedEventArgs e)
    {
        if (e.Property.Name == "GroupBoxStyle")
        {
            if ((string)e.NewValue == "Standard")
            {
                this.radGroupBox1.GroupBoxElement.Header.Fill.BackColor = Color.Aqua;
            }
            else
            {
                this.radGroupBox1.GroupBoxElement.Header.Fill.BackColor = Color.Gray;
            }
        }
    }

    You can subscribe to this event with the following line of code:
    radGroupBox1.GroupBoxElement.Header.RadPropertyChanged += Header_RadPropertyChanged;

    I hope this helps. Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  6. Jason
    Jason avatar
    47 posts
    Member since:
    Jan 2013

    Posted 31 Mar 2014 in reply to Dimitar Link to this post

    Thanks. Works like a charm
Back to Top
UI for WinForms is Visual Studio 2017 Ready