C# 美化 Windows 窗体应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11768747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Beautifying a Windows Form application
提问by unknownsatan
I will be creating a small database-driven Windows Formsapplication for my C# project. I wanted to beautify it like we do on web sites using CSS. Are there any resources or sites which can help me in beautifying my application?
我将为我的 C# 项目创建一个小型的数据库驱动的Windows 窗体应用程序。我想美化它,就像我们在使用CSS 的网站上所做的那样。是否有任何资源或网站可以帮助我美化我的应用程序?
回答by Eric J.
"Beautify" and "Windows Forms" are not often used in the same sentence. WPF allows for significantly better design opportunities.
“美化”和“Windows 窗体”并不经常用在同一个句子中。WPF 允许显着更好的设计机会。
Some frameworks allow you to skin a WinForms application, which allows you to drive look through configuration rather than code.
某些框架允许您为 WinForms 应用程序设置外观,这允许您通过配置而不是代码来驱动外观。
How do I skin my Windows Forms application?
There's also a CodeProject project that provides a skinner, though I have not used it personally
还有一个CodeProject项目提供了一个skinner,虽然我个人没有使用过
http://catalog.codeproject.com/Articles/415102/WinForms-Form-Skin
http://catalog.codeproject.com/Articles/415102/WinForms-Form-Skin
When I used to write small WinForms utilities without access to a framework, I would subclass each major control, and apply a style in that subclass. One change to the subclass affects the entire app.
当我过去在不访问框架的情况下编写小型 WinForms 实用程序时,我会将每个主要控件子类化,并在该子类中应用样式。对子类的一项更改会影响整个应用程序。
回答by Sean U
CSS-like styling is difficult in Windows Forms, because the framework wasn't really built with it in mind. If styling is important to you, then you will probably have a much easier time of it using WPF instead.
在 Windows 窗体中使用类似 CSS 的样式是困难的,因为该框架并没有真正考虑到它。如果样式对您很重要,那么您可能会更轻松地使用 WPF。
I know of one third-party library designed to help with skinning WinForms applications, DevExpress WinForms Skins. I don't have real experience with with it, though, so I can't make any comment on it.
我知道有一个第三方库旨在帮助为 WinForms 应用程序设计皮肤,DevExpress WinForms Skins。不过我没有这方面的实际经验,所以我不能对此发表任何评论。
回答by CodexVideos
If you google ".NET custom theme" then you can get many free styles to use in your projects.
如果您在 google 上搜索“.NET 自定义主题”,那么您可以获得许多可在您的项目中使用的免费样式。
Here is a list made by some user over at hackforums of his styles and custom controls, which I think help make your form 'Custom' and 'Nice': http://pastebin.com/1nvZ08kx
这是一些用户在他的样式和自定义控件的 hackforums 上制作的列表,我认为这有助于使您的表单成为“自定义”和“不错”:http: //pastebin.com/1nvZ08kx
回答by Patrick Pitre
You can't use CSS to style a WinForms application, but I don't think that's what you mean anyway.
您不能使用 CSS 来设计 WinForms 应用程序的样式,但我认为这不是您的意思。
As far as "beautifying" your application, there are a number of 3rd-party tools available. The most popular ones are (in no particular order):
至于“美化”您的应用程序,有许多 3rd 方工具可用。最受欢迎的是(排名不分先后):
- Telerik
- DevExpress
- Infragistics
- ComponentOne
- Many, many others
- 电信
- 开发速递
- 基础设施
- 组件一
- 许多许多其他人
People tend to get religious about their 3rd-party design tooling, and a lot of ink has been spilled on SO going over the benefits of each 3rd-party design tool.
人们倾向于对他们的 3rd 方设计工具变得虔诚,并且大量的墨水已经溢出到 SO 上,因为每个 3rd 方设计工具的好处。
回答by Danko Valkov
If you are interested in third-party tools for designing Windows Forms applications you could also take a look at the Infragistic's one - AppStylist for Windows Forms controls. There is a short video for the runtime version of this tool.
如果您对用于设计 Windows 窗体应用程序的第三方工具感兴趣,您还可以查看 Infragistic 的一个 - Windows 窗体控件的 AppStylist。此工具的运行时版本有一个简短的视频。
Another useful page for getting started is Application Styling Framework.
另一个有用的入门页面是Application Styling Framework。
回答by Tony Karel
I've used the WebBrowser control to create an interface before. With it you can use HTML and CSS to create a pretty nice looking "form". It requires a bit more coding, but it works. A user needs IE installed to use the control though. There is a VB.Net example here: Using VB .Net WebBrowser Control To Build WinForm User Interface
我以前使用 WebBrowser 控件创建了一个界面。有了它,您可以使用 HTML 和 CSS 创建一个非常漂亮的“表单”。它需要更多的编码,但它有效。用户需要安装 IE 才能使用该控件。这里有一个 VB.Net 示例: Using VB .Net WebBrowser Control To Build WinForm User Interface
In any case, it's another option.
无论如何,这是另一种选择。
回答by Nedo
You could try a library I built some time ago.
你可以试试我前段时间建的库。
http://www.codeproject.com/Articles/33716/Fancy-Windows-Forms
http://www.codeproject.com/Articles/33716/Fancy-Windows-Forms

