Example E933
Visible to All Users

Reporting for WinForms - Appearance Settings, Styles, Style Priority

This example shows a report with the following labels:

  • a label with appearance setting applied using a custom style
  • a label with appearance settings assigned directly in code
  • a label with appearance settings reset, so that the label takes appearance settings of the parent element

Report Styles and Priority

Files to Review

Documentation

More Examples

Example Code

XtraReport1.cs(vb)
C#
using System; using System.Drawing; using System.Drawing.Printing; using DevExpress.XtraPrinting; using DevExpress.XtraReports.UI; public partial class XtraReport1 : XtraReport { public XtraReport1() { InitializeComponent(); XRControlStyle myStyle = new XRControlStyle { Name = "MyStyle1", BackColor = Color.LightBlue, BorderColor = Color.LightGray, Borders = BorderSide.Top, BorderWidth = 2f, Font = new Font("Segoe Script", 16), ForeColor = Color.Green, TextAlignment = TextAlignment.TopCenter, }; this.StyleSheet.Add(myStyle); } private void xrLabel1_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) { ((XRLabel)sender).StyleName = "MyStyle1"; } private void XrLabel2_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) { ApplyAppearanceSettings((XRLabel)sender); } private void XrLabel3_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) { ApplyAppearanceSettings((XRLabel)sender); ResetStyle((XRLabel)sender); } // Assign custom appearance settings to a control. private void ApplyAppearanceSettings(XRLabel label) { label.BackColor = Color.Orange; label.BorderColor = Color.DarkGray; label.Borders = BorderSide.All; label.BorderWidth = 0.5f; label.Font = new Font(label.Parent.Font, FontStyle.Bold); label.ForeColor = Color.White; label.TextAlignment = TextAlignment.MiddleRight; } // Reset appearance settings and use parent control settings. private void ResetStyle(XRLabel label) { label.ResetBackColor(); label.ResetBorderColor(); label.ResetBorders(); label.ResetBorderWidth(); label.ResetFont(); label.ResetForeColor(); label.ResetPadding(); label.ResetTextAlignment(); } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.