FormattingRule.DataMember Property
Specifies which of the data fields that are available in a FormattingRule.DataSource can be used in constructing a formatting rule’s FormattingRule.Condition.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v18.2.dll
Declaration
Property Value
Type | Description |
---|---|
String | A String value, specifying a data member. |
Remarks
The FormattingRule.DataSource and DataMember properties together specify the list containing data fields that can participate in constructing the Boolean condition (accessed via the FormattingRule.Condition property).
Note that by default, the DataSource and DataMember properties are set to null (Nothing in Visual Basic), which means that a report’s XtraReportBase.DataSource and XtraReportBase.DataMember properties are used to obtain data fields for the condition.
Note
We recommend that you always specify a formatting rule’s data source and data member, to avoid an incorrect result.
In a master-detail setting, the DataMember property is specified using the following syntax: MasterTableName.DetailTableName.
To learn more, see Conditionally Changing a Control’s Appearance.
Example
This example demonstrates how to conditionally change a control’s appearance at runtime. For this, it is necessary to create an instance of the FormattingRule class, specify its FormattingRule.Condition and FormattingRule.Formatting properties and add this object to a report’s sheet of formatting rules (XtraReport.FormattingRuleSheet) and to the collection of formatting rules of a control or a band, to which it should be applied (XRControl.FormattingRules). Note that the same task can be also solved at design time, as described in the Conditionally Changing a Control’s Appearance topic.
Tip
Online Example: How to conditionally change control appearance
using System.Drawing;
using System.Drawing.Printing;
using DevExpress.XtraReports.UI;
// ...
private void XtraReport1_BeforePrint(object sender, PrintEventArgs e) {
// Create a new rule and add it to a report.
FormattingRule rule = new FormattingRule();
this.FormattingRuleSheet.Add(rule);
// Specify the rule's properties.
rule.DataSource = this.DataSource;
rule.DataMember = this.DataMember;
rule.Condition = "[UnitPrice] >= 30";
rule.Formatting.BackColor = Color.WhiteSmoke;
rule.Formatting.ForeColor = Color.IndianRed;
rule.Formatting.Font = new Font("Arial", 10, FontStyle.Bold);
// Apply this rule to the detail band.
this.Detail.FormattingRules.Add(rule);
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the DataMember 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.