logo DevExpress WinForm中文手册
文档首页>>DevExpress WinForm中文手册>>自定义皮肤注册

自定义皮肤注册


立即下载DevExpress WinForms

将皮肤库添加到项目中,并在应用程序启动时调用皮肤注册代码。

注册 DevExpress.BonusSkins 库

您可以注册BonusSkins库并在设计时对项目设置页面,如果主表单继承自XtraForm类或其子类,则项目设置和BonusSkins库注册代码将自动应用于表单的创建。

您也可以在代码中用DevExpress.UserSkins.BonusSkins.Register方法注册BonusSkins库,方法是在应用程序启动时调用它。

C#:

[STAThread]
static void Main() {
// Skin registration.
DevExpress.UserSkins.BonusSkins.Register();
Application.Run(new Form1());
}

VB.NET:

<STAThread> _
Shared Sub Main()
DevExpress.UserSkins.BonusSkins.Register()
'...
Application.Run(New frmMain())
End Sub

注册自定义皮肤

对于自定义皮肤,您可以从 WinForms Skin Editor中获取皮肤注册码。

以下示例显示了示例 SkinProject1 库的注册代码。

C#:

[STAThread]
static void Main() {
//If your custom skin is derived from a template skin that resides in the BonusSkins library, ensure that you register the template skin first using the BonusSkins.Register method.
//DevExpress.UserSkins.BonusSkins.Register()

Assembly asm = typeof(DevExpress.UserSkins.SkinProject1).Assembly;
DevExpress.Skins.SkinManager.Default.RegisterAssembly(asm);
Application.Run(new Form1());
}

VB.NET:

<STAThread> _
Shared Sub Main()
'If a custom skin's template resides in the BonusSkins library, ensure that you register the template skin first, using the BonusSkins.Register method.
'DevExpress.UserSkins.BonusSkins.Register()

Dim asm As Assembly = GetType(DevExpress.UserSkins.SkinProject1).Assembly
DevExpress.Skins.SkinManager.Default.RegisterAssembly(asm)
Application.Run(New frmMain())
End Sub

提示:如果自定义皮肤的模板驻留在BonusSkins库中,请确保首先使用BonusSkinsRegister方法注册模板皮肤,如上所示。

注册自定义皮肤用于启动屏幕和等待表单中使用

SplashScreenManager组件创建的启动屏幕和等待表单在另一个线程中运行,在主线程中注册的自定义皮肤信息在闪屏线程中是不可用的,直到您调用SplashScreenManagerRegisterUserSkins方法。

C#:

SplashScreenManager.RegisterUserSkins(typeof(DevExpress.UserSkins.SkinProject1).Assembly);
splashScreenManager1.ShowWaitForm();

VB.NET:

SplashScreenManager.RegisterUserSkins(GetType(DevExpress.UserSkins.SkinProject1).Assembly)
splashScreenManager1.ShowWaitForm()

如果自定义皮肤是从位于BonusSkins库中的一个模板皮肤派生的,在调用SplashScreenManagerRegisterUserSkins方法之前,请先在主线程中注册BonusSkins库。

扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP