Themes for WinForms | ComponentOne
C1.Win.C1Themes.Extended.4.8 Assembly / C1.Win.C1Themes Namespace / C1ThemePicker Class / ThemeApplying Event
Example

In This Topic
    ThemeApplying Event
    In This Topic
    Occurs before applying the selected theme. Allows to cancel the theme applying.
    Syntax
    'Declaration
     
    Public Event ThemeApplying As System.EventHandler(Of ThemeApplyingEventArgs)
    public event System.EventHandler<ThemeApplyingEventArgs> ThemeApplying
    Event Data

    The event handler receives an argument of type ThemeApplyingEventArgs containing data related to this event. The following ThemeApplyingEventArgs properties provide information specific to this event.

    PropertyDescription
    (Inherited from System.ComponentModel.CancelEventArgs)
    Gets or sets a value indicating whether the event was handled.  
    Gets the name of the theme to be assigned.  
    Remarks
    This event fires after a theme name is assigned or selected in the drop-down list, and allows the program to cancel the theme apply to form controls, if necessary.
    Example
    The code below handles the ThemeApplying event after theme name was assigned. As a result, the theme name was assigned to SelectedThemeName property, but the theme was not applied on the form due to "e.Handled = true".
    var c1ThemePicker1 = new C1ThemePicker();
    c1ThemePicker1.ThemeApplying += c1ThemePicker1_ThemeApplying;
                
    c1ThemePicker1.SelectedThemeName = "BeigeOne"; // assign theme name
                
    private void c1ThemePicker1_ThemeApplying(object sender, ThemeApplyingEventArgs e)
    {
        var themeName = e.ThemeName; // is "BeigeOne"
        e.Handled = true;            // The theme will not be applied to the form controls
    }
    See Also