Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
124 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...