How to reset the background color of a layout control?

7 posts, 0 answers
  1. Jürgen
    Jürgen avatar
    5 posts
    Member since:
    May 2014

    Posted 28 Oct Link to this post

    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

  2. Dimitar
    Admin
    Dimitar avatar
    1982 posts

    Posted 30 Oct Link to this post

    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.
  3. Jürgen
    Jürgen avatar
    5 posts
    Member since:
    May 2014

    Posted 30 Oct in reply to Dimitar Link to this post

    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.

  4. Dimitar
    Admin
    Dimitar avatar
    1982 posts

    Posted 31 Oct Link to this post

    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.
  5. Jürgen
    Jürgen avatar
    5 posts
    Member since:
    May 2014

    Posted 03 Nov in reply to Dimitar Link to this post

    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

  6. Dimitar
    Admin
    Dimitar avatar
    1982 posts

    Posted 03 Nov Link to this post

    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.
  7. Jürgen
    Jürgen avatar
    5 posts
    Member since:
    May 2014

    Posted 03 Nov in reply to Dimitar Link to this post

    Hello Dimitar,

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

    Regards,

    Jürgen

Back to Top