要定制特定控件的外观与感觉,可以使用它的 LookAndFeel 属性。 例如,编辑器的外观与感觉设置,可以通过它的 BaseEdit.Properties 对象的 RepositoryItem.LookAndFeel 属性进行访问 (参阅 BaseEdit.Properties 对象)。 XtraNavBar 控件的外观与感觉则使用 NavBarControl.LookAndFeel 属性进行访问,等等。
下列代码把 "Liquid Sky" 皮肤应用到 ButtonEdit 控件。
C# | 复制代码 |
---|---|
// Disable using the Default LookAndFeel. buttonEdit1.Properties.LookAndFeel.UseDefaultLookAndFeel = false; // Disable using the WindowsXP painting scheme. buttonEdit1.Properties.LookAndFeel.UseWindowsXPTheme = false; // Specify the skin to use. buttonEdit1.Properties.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin; buttonEdit1.Properties.LookAndFeel.SkinName = "Liquid Sky"; |
Visual Basic | 复制代码 |
---|---|
' Disable using the Default LookAndFeel. ButtonEdit1.Properties.LookAndFeel.UseDefaultLookAndFeel = False ' Disable using the WindowsXP painting scheme. ButtonEdit1.Properties.LookAndFeel.UseWindowsXPTheme = False ' Specify the skin to use. ButtonEdit1.Properties.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin ButtonEdit1.Properties.LookAndFeel.SkinName = "Liquid Sky" |
要为一组控件提供对外观与感觉设置的集中管理,可以使用下列方法之一:
- 把 样式控制器(Style Controller) 组件放置到窗体上,按需要定制它,并把它指派到所需控件的 BaseControl.StyleController 属性。 然后这些控件将使用由这个样式控制器公开的外观与感觉设置和外观(Appearance)设置。 请参阅 样式控制器(Style Controller) 文档获得更多信息。
注意: StyleController 技术由派生于 BaseControl 的控件支持 (编辑器、按钮、导航器、列表框等)。
- 新建一个 UserLookAndFeel 对象,并把它指派到这些控件的 UserLookAndFeel.ParentLookAndFeel 属性。 请参阅 UseDefaultLookAndFeel 设置 部分来获得关于 Parent LookAndFeel 对象的附加信息。
C# | 复制代码 |
---|---|
using DevExpress.XtraEditors; // Create and customize the Style Controller. StyleController styleController1 = new StyleController(); // Set the background color. styleController1.Appearance.BackColor = Color.LightYellow; // Customize the LookAndFeel settings. styleController1.LookAndFeel.UseDefaultLookAndFeel = false; styleController1.LookAndFeel.UseWindowsXPTheme = true; // Assign the StyleController to editors. buttonEdit1.StyleController = styleController1; lookUpEdit1.StyleController = styleController1; |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraEditors ' Create and customize the Style Controller. Dim styleController1 As StyleController = New StyleController() ' Set the background color. styleController1.Appearance.BackColor = Color.LightYellow ' Customize the LookAndFeel settings. styleController1.LookAndFeel.UseDefaultLookAndFeel = False styleController1.LookAndFeel.UseWindowsXPTheme = True ' Assign the StyleController to editors. ButtonEdit1.StyleController = styleController1 LookUpEdit1.StyleController = styleController1 |