The SftStyle.Styling event occurs for each control before the SftStyle component styles it in dark mode. Setting Cancel to True in the event data (StylingEventArgs) leaves that control as it is, for example a preview that must show the colors of a printout, or a control of another vendor that has a dark mode of its own. StylingEventArgs.Control is the control. Colors the control inherits from its parent, a BackColor or ForeColor it does not set itself, still follow the dark parent, so give an excluded control colors of its own, for example a BackColor of Color.White. Native menus, tool strips drawn with the ToolStripManager renderer and tooltips are styled for the whole application; the event cannot leave them out.
C#
private void sftStyle1_Styling(object sender, StylingEventArgs e) { if (e.Control == panelPrintPreview) e.Cancel = true; }
VB
Private Sub SftStyle1_Styling(sender As Object, e As StylingEventArgs) Handles SftStyle1.Styling If e.Control Is PanelPrintPreview Then e.Cancel = True End Sub
The event occurs once per control and switch: when the forms switch to dark mode, and for each form or control that appears while dark mode is active. On .NET 10 (or later) it also occurs when the forms switch back to light and when the component starts with forms open, since the refresh of open forms asks for every control. Its answer holds until the next switch. The child controls of an excluded control are styled independently: each gets the event of its own, so a handler that excludes a container and its contents checks the parents of StylingEventArgs.Control.
On .NET 10 (or later), the dark mode of Windows Forms itself still applies to an excluded control when its window is created. SftStyle leaves the control out of what it adds to that dark mode and out of the refresh of open forms (see .NET Framework and .NET 10).