示例:界面外观Examples:Look And Feel

How to: Customize the Look And Feel of a Specific Control(s)

1、如何定制指定控件的界面外观

All DevExpress controls expose the LookAndFeel property allowing you to change a control's look and feel settings. In most cases, this property is available directly in the control class; for instance, seeNavBarControl.LookAndFeel. There are however a few exceptions to this rule. If you are using an editor control, the same property is available underBaseEdit.Properties. (See the Editors Class Structure topic for more information on editor control implementation specifics.)

The following code applies "Seven Classic" skin to a ButtonEdit control.

C#
VB
// Disable using the Default LookAndFeel. 
buttonEdit1.Properties.LookAndFeel.UseDefaultLookAndFeel = false;
// Specify the skin to use. 
buttonEdit1.Properties.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
buttonEdit1.Properties.LookAndFeel.SkinName = "Seven Classic";


        
        
 
 
The result is illustrated below.

To provide centralized control over the LookAndFeel settings for a group of controls you can do one of the following:

  • place the StyleController  component onto a form, customize it according to your wishes and assign it to the required controls'BaseControl.StyleController properties. The controls will then use the LookAndFeel and Appearance settings exposed by this style controller. See theStyle Controller document for more information.

    Note: StyleController technology is supported by controls derived from BaseControl (editors, buttons, navigators, list boxes, etc.).

  • create a new UserLookAndFeel object and assign it to these controls' UserLookAndFeel.ParentLookAndFeel properties. See The UseDefaultLookAndFeel setting subsection for additional information on Parent LookAndFeel objects.
The code below shows how to customize the LookAndFeel settings of two editors by using the StyleController component.
C#
VB
注意这里使用的是 DevExpress.XtraEditors.StyleController
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;



       
       
 
 
The result is illustrated below.
How to: Customize the Look And Feel of all the Controls within a Form

2、如何:定制窗体中所有控件的界面外观

To provide centralized control over LookAndFeel settings of all the controls within a form, consider using the XtraForm form instead of the standard System.Windows.Forms.Form form.

集中定制窗体中的控件界面外观,考虑使用XtraForm窗体代替标准的System.Windows.Forms.Form窗体。

Customizing the LookAndFeel property of XtraForm will affect the LookAndFeel settings of all controls placed on a form.

定制XtraForm的LookAndFeel界面外观属性会影响窗台上所有控件的界面外观设置。

To replace the existing standard Form in your application with XtraForm in Visual Studio, just switch to the Code Editor and modify the class definition. For instance, locate the following line:

 
C#
public class Form1 : Form
 
 

and replace it with:

 
C#
public class Form1 : DevExpress.XtraEditors.XtraForm
 
 
Then build the project. Using the design-time Properties window, you can access the properties of the form, which now represent a XtraForm object.

When a control is placed onto XtraForm, the form's LookAndFeel object will serve as the Parent LookAndFeel for the control's LookAndFeel (the form's LookAndFeel object is automatically assigned to the control's UserLookAndFeel.ParentLookAndFeel property). The Parent LookAndFeel settings are in effect for a control if that control's UserLookAndFeel.UseDefaultLookAndFeel property is set to true (the default value). Thus you can set a specific control's UserLookAndFeel.UseDefaultLookAndFeel property to false to prevent XtraForm's LookAndFeel settings from affecting this control. 你可以设置特定控件的UserLookAndFeel.UseDefaultLookAndFeel属性为false来避免XtraForm的界面外观设置影响到当前控件。

See also the How to: Customize the Look And Feel of All the Controls within an Application topic, which demonstrates another way to manage the look and feel of multiple controls.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值