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

How to reset the background color of a layout control?

6 Answers 732 Views
LayoutControl
This is a migrated thread and some comments may be shown as answers.
Jürgen
Top achievements
Rank 1
Jürgen asked on 28 Oct 2017, 08:29 AM

Hello,

I'm able to set the background color of the layout control by setting its BackColor property to a Color value but I can't find a way to reset the background color to the Theme's default. The Method ResetValue() is not available for RadLayoutControl.

Any help would be appreciated!

Thanks

Jürgen

6 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 30 Oct 2017, 11:56 AM
Hello Jurgen,

Only RadElements have the ResetValue method. In this case, you can set the color of the root element:
private void radButton1_Click(object sender, EventArgs e)
{
    radLayoutControl1.RootElement.BackColor = Color.Red;
}
 
private void radButton2_Click(object sender, EventArgs e)
{
    radLayoutControl1.RootElement.ResetValue(RadItem.BackColorProperty, ValueResetFlags.Local);
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jürgen
Top achievements
Rank 1
answered on 30 Oct 2017, 01:07 PM

Hello Dimitar,

Thanky you very much for your quick answer! Unfortunatelly your advise doesn't work. Any other suggestion would be much appreciated!

Thanks

Jürgen

By the way: I use version 2016.3.1024.40.

0
Dimitar
Telerik team
answered on 31 Oct 2017, 07:32 AM
Hello Jurgen,

I have tested this with the specified version and it still works. I have attached my test project. Could you please check it and let me know how it differs from your real setup? 

Thank you in advance for your patience and cooperation. 

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jürgen
Top achievements
Rank 1
answered on 03 Nov 2017, 09:52 AM

Hello Dimitar,

Thank you very much for your test project! It works but only with the default theme. When I set a specific theme (in my example Offive2010black) it doesn't work anymore. This is the modified code of your test project I used for my test:

public partial class RadForm1 : Telerik.WinControls.UI.RadForm
   {
       public RadForm1()
       {
           InitializeComponent();
           ThemeResolutionService.ApplicationThemeName = "Office2010Black";
       }
 
       private void radButton1_Click(object sender, EventArgs e)
       {
           radLayoutControl1.BackColor = Color.Red;
           // radLayoutControl1.RootElement.BackColor = Color.Red;
       }
 
       private void radButton2_Click(object sender, EventArgs e)
       {
           radLayoutControl1.RootElement.ResetValue(RadItem.BackColorProperty, ValueResetFlags.Local);
       }
   }

 

Thanky again for your help!

Regards,

Jürgen

1
Dimitar
Telerik team
answered on 03 Nov 2017, 11:03 AM
Hello Jurgen,

When the color of the root element is set all elements that do not have another color explicitly set will inherit the color from the root element. In this case, the ContainerElement is explicitly setting the BackColor and this is why there is no effect. So you need to change the BackColor of the ContainerElement:
private void radButton1_Click(object sender, EventArgs e)
{
    radLayoutControl1.ContainerElement.BackColor = Color.Red;
}
 
private void radButton2_Click(object sender, EventArgs e)
{
    radLayoutControl1.ContainerElement.ResetValue(RadItem.BackColorProperty, ValueResetFlags.Local);
}

I hope this will be useful.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jürgen
Top achievements
Rank 1
answered on 03 Nov 2017, 01:02 PM

Hello Dimitar,

with the changes you suggested it works now as expedted. Thanks again for your well-founded support!

Regards,

Jürgen

Tags
LayoutControl
Asked by
Jürgen
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Jürgen
Top achievements
Rank 1
Share this question
or