Skip to content

Creating a Themeable form

anarchie347 edited this page May 15, 2023 · 2 revisions

Creating a themeable form

To make your form work with themeable controls, you must make it inherit from Anarchie.Themes.ThemeableForm If you are using Visual Studio, then at the top of Form1.cs, change

public partial class Form1 : Form

to

public partial class Form1 : ThemeableForm<Theme>

Replace Theme with whatever Theme schema you are using. It must inherit from Theme

and add using Anarchie.Themes to the top of the file

Doing this will mean that the designer tool in visual studio will no longer work.

Now go to the constructor method, and change

public Form1() {
  //code
}

to

public Form1() : base(DefautTheme) {
  //code
}

Replace DefaultTheme with whatever theme the program will use to begin with. To change the theme later, edit the CurrentTheme property of the ThemeableForm.

Clone this wiki locally