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

Theming RadGroupBox

4 Answers 22 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 07 Mar 2014, 09:56 AM
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

4 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 12 Mar 2014, 07:24 AM
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.

0
Jason
Top achievements
Rank 1
answered on 27 Mar 2014, 08:36 AM
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
0
Accepted
Dimitar
Telerik team
answered on 28 Mar 2014, 03:56 PM
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.

 
0
Jason
Top achievements
Rank 1
answered on 31 Mar 2014, 07:33 AM
Thanks. Works like a charm
Tags
Themes and Visual Style Builder
Asked by
Jason
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Jason
Top achievements
Rank 1
Share this question
or