.net 如何更改整个应用程序的默认 LookAndFeel?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4790508/
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
How to change the default LookAndFeel for the entire application?
提问by calico-cat
This pagelists a way to change the default LookandFeel for a .net application using DevExpress 10.2. It's not working for me.
此页面列出了使用 DevExpress 10.2 更改 .net 应用程序的默认 LookandFeel 的方法。它对我不起作用。
My code (in Main())
我的代码(在Main())
imports DevExpress.LookAndFeel
DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Caramel"
DevExpress.LookAndFeel.UserLookAndFeel.Default.UseWindowsXPTheme = False
DevExpress.LookAndFeel.UserLookAndFeel.Default.LookAndFeelStyle.Office2003
My users hate this new grey theme and want Caramel back... suggestions?
我的用户讨厌这个新的灰色主题并希望 Caramel 回来......建议?
回答by Stephan Keller
Your code should work. But you have to make sure that all your forms are derived from DevExpress.XtraEditors.XtraForm (for a Winforms-Application). Otherwise the LookAndFeel will not be propagated to the controls on the forms. In general: if you place a devexpress control in a container that is not derived from a devexpress container the look-and-feel will not change.
您的代码应该可以工作。但是你必须确保你的所有表单都来自 DevExpress.XtraEditors.XtraForm(对于 Winforms 应用程序)。否则 LookAndFeel 将不会传播到窗体上的控件。一般而言:如果您将 devexpress 控件放置在不是从 devexpress 容器派生的容器中,外观将不会改变。
Edit: the original question & answer was for DevExpress v 10.x. Starting with DevExpress V 2011.2 you need to reference a "DevExpress.BonusSkins.vXX.Y"-library in your project and register the bonus skins via
编辑:最初的问题和答案是针对 DevExpress v 10.x 的。从 DevExpress V 2011.2 开始,您需要在您的项目中引用“DevExpress.BonusSkins.vXX.Y”库并通过以下方式注册奖励皮肤
DevExpress.UserSkins.BonusSkins.Register();
The bonus skin libraries are called e.g. "DevExpress.BonusSkins.v12.1.DLL" and can be found in the "\Bin\Framework"-Folder of your DevExpress-installation.
奖励皮肤库被称为例如“DevExpress.BonusSkins.v12.1.DLL”,可以在您的 DevExpress 安装的“\Bin\Framework”文件夹中找到。
Complete code would look like:
完整的代码如下所示:
DevExpress.UserSkins.BonusSkins.Register();
DefaultLookAndFeel defaultLF = new DefaultLookAndFeel();
defaultLF.LookAndFeel.UseDefaultLookAndFeel = true;
回答by Ultimacho
When you create a project that uses any Developer Express component, a reference to the DevExpress.Utilslibrary is added to it. This library contains helper classes common to all components and also provides some default skins
创建使用任何 Developer Express 组件的项目时,会向其中DevExpress.Utils添加对该库的引用。这个库包含所有组件通用的辅助类,还提供了一些默认皮肤
(e.g. DevExpress Style, Metropolis, VS2010, Office 2010 Blue, etc.).
(例如 DevExpress Style、Metropolis、VS2010、Office 2010 Blue 等)。
Other skins
其他皮肤
(Caramel, Coffee, Liquid Sky, Stardust, etc.)
(焦糖、咖啡、液态天空、星尘等)
are implemented in the DevExpress.BonusSkins library
在 DevExpress.BonusSkins 库中实现
To register skins shipped with the DevExpress.BonusSkins library, call the static Register method of the DevExpress.UserSkins.BonusSkinsclass.
要注册 DevExpress.BonusSkins 库附带的皮肤,请调用DevExpress.UserSkins.BonusSkins该类的静态 Register 方法。
[STAThread]
static void Main() {
// Skin registration.
DevExpress.UserSkins.BonusSkins.Register();
Application.Run(new Form1());
}
See this linkfor more details.
有关更多详细信息,请参阅此链接。
回答by Josué
After i read much, i did like this and run me perfect!
在我阅读了很多之后,我确实喜欢这个并且完美地运行了我!
1 - Create a module and write this code:
1 - 创建一个模块并编写以下代码:
Imports DevExpress.LookAndFeel Module Program <STAThread()> _ Public Sub Main() DevExpress.UserSkins.BonusSkins.Register() DevExpress.UserSkins.OfficeSkins.Register() DevExpress.LookAndFeel.UserLookAndFeel.Default.UseWindowsXPTheme = False DevExpress.LookAndFeel.UserLookAndFeel.Default.UseDefaultLookAndFeel = True DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Caramel" 'For Example! DevExpress.Skins.SkinManager.EnableMdiFormSkins() DevExpress.Skins.SkinManager.EnableFormSkins() Application.Run(New Form1) End Sub End Module
Imports DevExpress.LookAndFeel Module Program <STAThread()> _ Public Sub Main() DevExpress.UserSkins.BonusSkins.Register() DevExpress.UserSkins.OfficeSkins.Register() DevExpress.LookAndFeel.UserLookAndFeel.Default.UseWindowsXPTheme = False DevExpress.LookAndFeel.UserLookAndFeel.Default.UseDefaultLookAndFeel = True DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Caramel" 'For Example! DevExpress.Skins.SkinManager.EnableMdiFormSkins() DevExpress.Skins.SkinManager.EnableFormSkins() Application.Run(New Form1) End Sub End Module
2 - And OBVIOUSLY Change this line in each form (Form1.Designer.vb):
2 - 并且显然在每个表单中更改此行(Form1.Designer.vb):
Partial Class Form1 REM Inherits System.Windows.Forms.Form Inherits DevExpress.XtraEditors.XtraForm End Class
Partial Class Form1 REM Inherits System.Windows.Forms.Form Inherits DevExpress.XtraEditors.XtraForm End Class
Good luck!
祝你好运!
回答by DevExpress Team
The following code should work for you:
以下代码应该适合您:
DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Caramel"
DevExpress.LookAndFeel.UserLookAndFeel.Default.UseWindowsXPTheme = False
回答by Jens Kloster
Try setting the LookAndFeelStyle to "Skin":
尝试将 LookAndFeelStyle 设置为“皮肤”:
DevExpress.LookAndFeel.UserLookAndFeel.Default.LookAndFeelStyle.Skin

