Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I apply my own theme to my Windows Forms application?

Tags:

c#

.net

winforms

On executing a Windows Forms application in C# the view of the form looks the same as the theme of Windows.

How can I give my own theme to my application which doesn't depend upon the Windows theme?

like image 786
Javed Akram Avatar asked Nov 03 '10 12:11

Javed Akram


People also ask

How do I change the background in Windows form?

Set the background in the Windows Forms DesignerSelect the Web or System tab to display a list of predefined names for colors, and then select a color. In the Properties window, click the arrow button next to the BackgroundImage property. In the Open dialog box, select the file that you want to display.

Which template would create a Windows Forms based application?

On the start window, select Create a new project. On the Create a new project window, select the Windows Forms App (. NET Framework) template for C#.


1 Answers

You can't do that easily. There are several alternatives at your disposal.

  1. The simplest way is to create a Skin XML file of your own, in which you specify your own colors for your Application, you read it via a Class you create as well and you apply the new colors. This will keep things separated and ready for future changes. But note that you still won't be able to change how the Title Bar is rendered and other system-specific things, such as how the X and Maximize buttons look.

  2. Expanding on point 1, you could create your forms as borderless and create your window with custom painting (override OnPaint) and images. This is harder to accomplish. You may want to inherit from the Form class and create your own CustomDrawnForm which you will use across your application.

  3. Use one of the many control libraries out there, such as DevExpress. Some are free, some are expensive.

What you're trying to do is not very simple in Windows.Forms, and maybe you should look at WPF and other alternatives.

like image 53
Axonn Avatar answered Nov 14 '22 21:11

Axonn