xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrcontrol-33e867ce.md
Allows you to specify properties whose values for an individual control have priority over the same properties specified for the style assigned to the control.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
[SRCategory(ReportStringId.CatAppearance)]
public virtual StylePriority StylePriority { get; }
<SRCategory(ReportStringId.CatAppearance)>
Public Overridable ReadOnly Property StylePriority As StylePriority
| Type | Description |
|---|---|
| StylePriority |
A StylePriority object, which contains style priority settings.
|
In a default style scenario, the style properties take precedence over the property values set for an individual control. This means that all properties of the StylePriority object returned by the StylePriority property are set to true.
If you want a property value of the control to apply rather than the style value, set the appropriate Use... property to false. In other words, to make the control use its own individual background color, set the StylePriority.UseBackColor property to false.
The following code snippet creates two labels with different background colors. The myLabel1 control has a light blue background determined by the MyStyle1 style’s XRControlStyle.BackColor property. The mylabel2 control has an orange background determined by the control’s BackColor property.
using System;
using System.Drawing;
using DevExpress.XtraReports.UI;
// ...
XtraReport myReport = new XtraReport();
myReport.Bands.Add(new DetailBand());
XRControlStyle myStyle = new XRControlStyle {
Name = "MyStyle1",
BackColor = Color.LightBlue
};
myReport.StyleSheet.Add(myStyle);
XRLabel myLabel1 = new XRLabel {
Text = "One",
StyleName = "MyStyle1",
BackColor = Color.Black,
LocationF = new PointF(0F, 0F)
};
XRLabel myLabel2 = new XRLabel {
Text = "Two",
BackColor = Color.Orange,
StyleName = "MyStyle1",
LocationF = new PointF(200F, 0F),
};
myLabel2.StylePriority.UseBackColor = false;
myReport.Bands[BandKind.Detail].Controls.AddRange(
new XRControl[] { myLabel1, myLabel2 });
Imports DevExpress.XtraReports.UI
' ...
Dim myReport As New XtraReport()
myReport.Bands.Add(New DetailBand())
Dim myStyle As New XRControlStyle With {
.Name = "MyStyle1",
.BackColor = Color.LightBlue
}
myReport.StyleSheet.Add(myStyle)
Dim myLabel1 As New XRLabel With {
.Text = "One",
.StyleName = "MyStyle1",
.BackColor = Color.Black,
.LocationF = New PointF(0F, 0F)
}
Dim myLabel2 As New XRLabel With {
.Text = "Two",
.BackColor = Color.Orange,
.StyleName = "MyStyle1",
.LocationF = New PointF(200.0F, 0F)
}
myLabel2.StylePriority.UseBackColor = False
myReport.Bands(BandKind.Detail).Controls.AddRange(New XRControl() {myLabel1, myLabel2})
For more information about styles and style inheritance in DevExpress Reporting, review the following help topic: Report Visual Styles.
See Also