Edytuj

Udostępnij za pośrednictwem


Application.SetColorMode(SystemColorMode) Method

Definition

Sets the default color mode (dark mode) for the application.

public:
 static void SetColorMode(System::Windows::Forms::SystemColorMode systemColorMode);
[System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public static void SetColorMode (System.Windows.Forms.SystemColorMode systemColorMode);
[<System.Diagnostics.CodeAnalysis.Experimental("WFO5001", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
static member SetColorMode : System.Windows.Forms.SystemColorMode -> unit
Public Shared Sub SetColorMode (systemColorMode As SystemColorMode)

Parameters

systemColorMode
SystemColorMode

The application's default color mode (dark mode) to set.

Attributes

Remarks

You should use this method to set the default color mode (dark mode) for the application. Set it before creating any UI elements to ensure that the correct color mode is used. You can set it to dark mode (Dark), light mode (Classic) or to the system setting (System).

If you set it to System, the actual color mode is determined by the Windows system settings. If the system setting is changed, the application will not automatically adapt to the new setting.

Note that the dark color mode is only available from Windows 11 on or later versions. If the system is set to a high contrast mode, the dark mode is not available.

Note for Visual Basic: If you are using the Visual Basic Application Framework, you should set the color mode by handling the Application Events (see ApplyApplicationDefaults).

Applies to