Skip to main content

TcxCustomEditStyle Class

Represents the properties that control the look & feel of an editor.

Declaration

TcxCustomEditStyle = class(
    TcxContainerStyle
)

Remarks

The TcxCustomEditStyle class contains a set of properties that control the look & feel of an edit control. You can set the border color, border and button styles, font and many other attributes.

The LookAndFeel property determines the default look & feel of an editor. When working in Windows XP, you can enable the native style by setting the LookAndFeel.NativeStyle attribute to True. The LookAndFeel.Kind, and LookAndFeel.SkinName attributes determine the default look & feel of editor borders, buttons and highlighting effects.

You can override the default look & feel of an editor by assigning appropriate style attributes. When you assign style attributes, the corresponding flags are set in the AssignedValues property. This indicates that the corresponding style attributes were overridden and are used to display editor elements. You can use the RestoreDefaults method to clear all the flags in the AssignedValues property, thus restoring the default values of the assigned style attributes. Note that changes to the look & feel attributes are tracked explicitly as the LookAndFeel property has its own AssignedValues property.

The style controller enables you to define the same style settings for more than one editor. Place a TcxEditStyleController instance onto a form and set the StyleController property of an edit control to the style controller. The TcxEditStyleController.Style property contains style settings common to several editors.

The default style controller lets you define the same style settings for all editors that have no style controller assigned. With a TcxDefaultEditStyleController instance placed onto a form you can control the appearance of all editors within your application by a single mouse click. This greatly simplifies the customization of your application’s appearance.

If a specific style attribute is assigned either via an editor style or via the style controller linked to the editor, this attribute value will be used to display an edit control. Otherwise, there are two cases to consider:

  • Both the editor and the linked style controller have the same style attribute assigned to some value. In this case the value of the editor’s style attribute overrides the attribute value of the style controller.

  • Neither the editor nor the style controller has a specific style attribute assigned. In this case the editor uses the default value of this style attribute determined by the LookAndFeel.Kind property.

For instance, you can define the same style attributes via the style controller, apply them to two edit controls and then, for instance, redefine Font for one editor. When you assign a value to the TcxCustomEdit.Style.Font property the corresponding svFont flag is set in TcxCustomEdit.Style.AssignedValues. It indicates that the font value should be obtained from the TcxCustomEdit.Style.Font property and not from the font attribute of the style controller.

Suppose we have two editors and the style controller linked to these editors.

cxTextEdit1.Style.Font.Name := 'Courier';
  cxTextEdit1.Style.StyleController := cxEditStyleController1;
  cxTextEdit2.Style.StyleController := cxEditStyleController1;
  cxEditStyleController1.Style.Font.Name := 'Comic Sans MS';
  cxEditStyleController1.Style.BorderStyle := ebsSingle;

In this example, the cxTextEdit2 editor will use the font and border styles from the style controller. The cxTextEdit1 editor is drawn with the Courier font but the border style for the editor is defined by the style controller. Other style attributes are not assigned either to the editor style or to the style controller and therefore are defined by the default values set in the editor style.

See Also