Issue with EmptyArea Not Working When Using C1ThemeController

Posted by: andrea.davoli on 1 April 2025, 9:52 am EST

  • Posted 1 April 2025, 9:52 am EST - Updated 1 April 2025, 9:57 am EST

    Hi everyone,

    I’m experiencing an issue with the EmptyArea not working when applying themes using C1ThemeController. Without a theme, the EmptyArea behaves as expected, but once a theme is applied, it seems to stop functioning.

    Is this a known issue, or am I missing something in the configuration?

    This is the component

    I put a Theme with the component

    Then I put styles - EmptyArea - backcolor - white.

    When I compile and run the program, I find it like this: it didn’t apply the white EmptyArea

    I can set it via code, but sometimes it briefly shows the wrong EmptyArea before displaying the correct one. It should work directly through the designer.

    Thank you!

  • Posted 2 April 2025, 1:17 am EST

    Hello,

    When a Theme is used, styling properties are overridden by Theme styles. To overcome this behavior, you can create your custom Theme or change the Theme property at run-time as follows:

    public Form1()
    {
        InitializeComponent();
    
        // Get theme by name. 
        var theme = C1ThemeController.GetThemeByName("Office2010Blue", true);
        SetBackgroundProperty(theme, "C1FlexGrid\\Styles\\EmptyArea\\Background", Color.White);
        C1ThemeController.ApplyThemeToControlTree(this, theme);
    }
    
    private bool SetBackgroundProperty(C1Theme theme, string propPath, Color color)
    {
        if (theme != null)
        {
            // Get the color property at the specified path.
            var prop = theme.Children.GetItemByPath(propPath) as BackgroundProp;
            if (prop != null)
            {
                prop.Value = ThemeBackground.White;
                return true;
            }
        }
        return false;
    }

    If you set it at run-time, EmptyArea’s BackColor will not be visible in the designer.

    For more information on creating your custom theme, please refer to https://developer.mescius.com/componentone/docs/win/online-themes/overview.html.

    To get the path to the theme property, you can right-click the desired property in C1ThemeDesigner → Copy Name → Name.

    Please refer to the attached sample for implementation of the run-time method. (see FlexGrid_ThemeSample.zip)

    Regards,

    Uttkarsh.

  • Posted 3 April 2025, 11:32 am EST

    Thank you!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels