Difference between revisions of "DarkMode.cs"
m |
m |
||
| Line 8: | Line 8: | ||
== Script == | == Script == | ||
'''Download:''' [[Media:DarkMode.cs|DarkMode.cs]]<br> | '''Download:''' [[Media:DarkMode.cs|DarkMode.cs]]<br> | ||
| + | |||
'''GitHub:''' https://github.com/d-v-d-k/DarkMode.cs<br> | '''GitHub:''' https://github.com/d-v-d-k/DarkMode.cs<br> | ||
== Usage == | == Usage == | ||
| − | |||
Add DarkMode.cs to the project solution.<br> | Add DarkMode.cs to the project solution.<br> | ||
| + | [[File:DarkMode Solution.png|frame|224px|left]]<br> | ||
| + | <br> | ||
| + | <br> | ||
| + | <br> | ||
| + | <br> | ||
| + | <br> | ||
| + | <br> | ||
| + | <br> | ||
=== Enable === | === Enable === | ||
<code>DarkMode.Enable(form);</code><br> | <code>DarkMode.Enable(form);</code><br> | ||
| − | Enable Dark Mode style on this Form. | + | Enable Dark Mode style on this Form.<br> |
| − | Example: On each Form Initialize Event | + | ''Example:'' On each Form Initialize Event |
<pre> | <pre> | ||
public Form1() | public Form1() | ||
| Line 28: | Line 36: | ||
</pre> | </pre> | ||
| − | Example: When creating a Form instance | + | ''Example:'' When creating a Form instance |
<pre> | <pre> | ||
Form1 form = new Form1(); | Form1 form = new Form1(); | ||
Revision as of 07:32, 25 April 2026
Contents
Class
A C# Class for .NET Framework 2.0 - 4.8.1 (Windows 98 - Windows 11) to enable Dark Mode on Windows Forms.
By default only .NET 9.0 (no Framework) and higher supports Dark Mode natively, which is an optional download for Windows 10/11 only.
Script
Download: DarkMode.cs
GitHub: https://github.com/d-v-d-k/DarkMode.cs
Usage
Add DarkMode.cs to the project solution.
Enable
DarkMode.Enable(form);
Enable Dark Mode style on this Form.
Example: On each Form Initialize Event
public Form1()
{
InitializeComponent();
DarkMode.Enable(this);
}
Example: When creating a Form instance
Form1 form = new Form1(); DarkMode.Enable(form); form.Show();
Inherit
DarkMode.Inherit(form);
Inherit and apply the current Windows User Dark/Light Mode preference to this Form.
Only works in Windows 10/11, otherwise Inherit will automatically default to standard Light Mode (change with DarkMode.UserDefault).
Disable
DarkMode.Disable(form);
Revert this Form back to default Light Mode style.


