Back to Devexpress

XRControl.Padding Property

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrcontrol-80c464f5.md

latest7.5 KB
Original Source

XRControl.Padding Property

Gets or sets the control’s padding values (measured in report units).

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
[SRCategory(ReportStringId.CatAppearance)]
public virtual PaddingInfo Padding { get; set; }
vb
<SRCategory(ReportStringId.CatAppearance)>
Public Overridable Property Padding As PaddingInfo

Property Value

TypeDescription
PaddingInfo

A PaddingInfo object that specifies the padding values.

|

Remarks

The Padding property specifies indent values which are used to render the control’s contents (for example, an XRLabel‘s text or an XRPictureBox‘s image).

Initial Values

Report controls that display text information (XRLabel, XRTableCell, XRPageInfo, XRRichText and XRCheckBox) have initial right and left padding values set to 2. The XRBarCode control’s paddings are initially set to 10.

How to Specify the Padding

At design time, you can use the Properties window to change the control’s paddings.

The following code snippet specifies the paddings for the XRLabel control:

csharp
xrlabel2.Padding = new DevExpress.XtraPrinting.PaddingInfo(20, 2, 2, 0);
vb
xrlabel2.Padding = New DevExpress.XtraPrinting.PaddingInfo(20, 2, 2, 0)

If the Padding property is not set for a report control, the Padding value is obtained from the control’s parent. That means that Padding value of the current control applies to all its child report controls (if there are any in its XRControl.Controls collection) if their Padding property value is not set. Refer to the following topic for more information: Appearance Properties.

Note

Not all descendants of the XRControl class use the Padding property. For example, the XRPageBreak class and Band class descendants ignore the Padding property.

Export to Different Formats

The Padding property is ignored when a report is exported to RTF and DOCX formats.

When exporting a report document to XLS or XLSX, control paddings are automatically converted to Excel’s indents (since Excel does not support the concept of paddings). Indents specify the horizontal space between the cell border and the cell data itself. Only one padding value (PaddingInfo.LeftF or PaddingInfo.RightF) is taken into account, depending on whether the control’s content is left-aligned or right-aligned, which is specified by the XRControl.TextAlignment and the control’s RightToLeft properties.

1 indent usually takes 3 spaces of the current font size, which is approximately equal to 9 pixels under the default settings. For this reason, when exporting documents, each 9 pixels of the corresponding Padding property value is converted to 1 Excel cell indent.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Padding 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.

reporting-web-forms-handle-server-side-errors/CS/DXWebApplication1/Reports/XtraReport3.cs#L63

csharp
this.xrLabel1.Name = "xrLabel1";
this.xrLabel1.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
this.xrLabel1.SizeF = new System.Drawing.SizeF(100F, 23F);

reporting-wpf-use-private-custom-font-distributed-with-application/VB/PrivateFontDemo/SampleReport.vb#L31

vb
Detail.Name = "Detail"
Detail.Padding = New DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F)
Detail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft

reporting-web-forms-handle-server-side-errors/VB/DXWebApplication1/Reports/XtraReport3.vb#L61

vb
Me.xrLabel1.Name = "xrLabel1"
Me.xrLabel1.Padding = New DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F)
Me.xrLabel1.SizeF = New System.Drawing.SizeF(100F, 23F)

See Also

Appearance Properties

Report Visual Styles

Conditionally Change the Control's Appearance

XRControl Class

XRControl Members

DevExpress.XtraReports.UI Namespace