DarkMode.cs

From DanIT
Revision as of 00:39, 25 April 2026 by Dan (talk | contribs) (Created page with "thumb|right C# Class for .NET Framework 2.0 - 4.8.1 (latest) to enable Dark Mode on Forms.<br> By default only .NET 9.0 and higher supports Dark Mode nati...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

C# Class for .NET Framework 2.0 - 4.8.1 (latest) to enable Dark Mode on Forms.
By default only .NET 9.0 and higher supports Dark Mode natively, which is an optional download for Windows 10/11.

Script

Download DarkMode.cs

test

Usage

Enable

DarkMode.Enable(this);

Enable Dark Mode style on this Form.

On each Form Load Event, simply add the following line to enable Dark Mode, example:

private void Form1_Load(object sender, EventArgs e)
{
    DarkMode.Enable(this);
}

Example:

Form1 form = new Form1();
DarkMode.Enable(form);
form.Show();

Inherit

DarkMode.Inherit(this);

Inherit and apply the current Windows User Dark/Light Mode to this Form.

Disable

DarkMode.Disable(this);

Revert this Form back to default Light Mode style.