windowsforms-devexpress-dot-xtraeditors-dot-formatconditionruleappearancebase-c0b955ad.md
Gets or sets the name of a predefined or custom style applied to target cells.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DefaultValue("")]
[DXCategory("Appearance")]
[XtraSerializableProperty]
public string PredefinedName { get; set; }
<XtraSerializableProperty>
<DXCategory("Appearance")>
<DefaultValue("")>
Public Property PredefinedName As String
| Type | Default | Description |
|---|---|---|
| String | String.Empty |
A string that specifies the name of a predefined style.
|
The following styles are supported out of the box:
You can add custom styles in code by using the FormatPredefinedAppearances.AddCustomFormatAppearance method, as demonstrated in the example at the end of the topic.
At design time, you can set the PredefinedName property to one of predefined styles using a dropdown list provided by the property. Custom styles, which are added in code, are not available in this list at design time.
At runtime, an end-user is able to specify an appearance style (predefined or custom) for format rules from dedicated dialog boxes.
A custom appearance can be provided for format rules by directly customizing the appearance attributes (background color, foreground color and font settings). Use the FormatConditionRuleAppearanceBase.Appearance property to do this. Note that the appearance style assigned to the PredefinedName property is ignored when the FormatConditionRuleAppearanceBase.Appearance property is customized.
FormatConditionRuleAppearanceBase class descendants support a limited number of predefined appearance styles. To add more styles, use the static DevExpress.XtraEditors.Helpers.FormatPredefinedAppearances.AddCustomFormatAppearance method, which is declared as follows:
public static void AddCustomFormatAppearance(string key, string title, AppearanceDefault appearance, bool isDark)
The following code creates two appearance styles that have the same key and title (“My Orange”) and provide different appearance settings for the light and dark skins.
AppearanceDefault appearanceLight = new AppearanceDefault();
appearanceLight.BackColor = Color.FromArgb(255, 247, 129, 25);
appearanceLight.ForeColor = Color.White;
FormatPredefinedAppearances.AddCustomFormatAppearance("My Orange", "My Orange", appearanceLight, false);
AppearanceDefault appearanceDark = new AppearanceDefault();
appearanceDark.BackColor = Color.Black;
appearanceDark.ForeColor = Color.Orange;
FormatPredefinedAppearances.AddCustomFormatAppearance("My Orange", "My Orange", appearanceDark, true);
The following animation demonstrates the selection of this custom style for a grid column at runtime (the GridOptionsMenu.ShowConditionalFormattingItem option is enabled) and how the column’s formatted cells automatically change their appearances when switching from the default light skin to a dark skin.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PredefinedName property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-grid-bind-to-business-objects/CS/GridBoundToRuntimeCreatedData/Form1.cs#L40
gridFormatRule.Column = gridView1.Columns["RequiredDate"];
formatConditionRuleValue.PredefinedName = "Red Bold Text";
formatConditionRuleValue.Condition = FormatCondition.Greater;
winforms-grid-bind-to-business-objects/VB/GridBoundToRuntimeCreatedData/Form1.vb#L42
gridFormatRule.Column = gridView1.Columns("RequiredDate")
formatConditionRuleValue.PredefinedName = "Red Bold Text"
formatConditionRuleValue.Condition = FormatCondition.Greater
See Also
FormatConditionRuleAppearanceBase Class