XRLabel.LineSpacing Property
Gets or sets the spacing between lines of text in an XRLabel or XRTableCell.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v25.1.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
[DefaultValue(1F)]
[SRCategory(ReportStringId.CatLayout)]
public virtual float LineSpacing { get; set; }
Property Value
Type | Default | Description |
---|---|---|
Single | 1 | The line spacing value. |
Remarks
Use LineSpacing
to specify the vertical space between lines in basic report controls. Line spacing reduces report memory usage and offers more precise layout customization.
Important
The LineSpacing
setting is ignored if the AllowMarkupText option is enabled.
Example: XRLabel
The following code snippet creates an XRLabel
, sets its text, and adjusts the line spacing:
using DevExpress.XtraReports.UI;
using System;
using System.Drawing;
namespace DXApplication {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
this.Load += Form1_Load;
}
void Form1_Load(object sender, EventArgs e) {
XtraReport report = new XtraReport();
// Create a Detail band.
DetailBand detail = new DetailBand();
report.Bands.Add(detail);
// Create a label and set its properties.
XRLabel label = new XRLabel() {
Text = "DevExpress Reports ship with an intuitive Visual Studio Report Designer, runtime Report Designers/Report Viewers for ASP.NET/Blazor/WPF/WinForms/Mobile, and a rich set of report controls, including cross tabs/charts so you and your users can create reports of unmatched elegance and informational clarity.",
LineSpacing = 1.5f, // Increase line spacing.
BoundsF = new RectangleF(0, 0, 300, 100)
};
detail.Controls.Add(label);
// Preview the report.
ReportPrintTool tool = new ReportPrintTool(report);
tool.ShowPreviewDialog();
}
}
}
The image below shows the result:
Example - XRTableCell
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting;
using System;
namespace DXApplication {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
Load += Form1_Load;
}
void Form1_Load(object sender, EventArgs e) {
XtraReport report = new XtraReport();
// Create a Detail band.
DetailBand detail = new DetailBand();
report.Bands.Add(detail);
// Create a table.
XRTable table = new XRTable();
table.BeginInit();
table.WidthF = 600;
table.Padding = new PaddingInfo(40, 0, 40, 0);
XRTableRow row = new XRTableRow();
// Sample long text
string sampleText =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
"Suspendisse potenti. Nulla facilisi.";
// Create three cells with the same sample text and custom line spacing.
for (int i = 0; i < 3; i++) {
XRTableCell cell = new XRTableCell() {
Text = sampleText,
LineSpacing = 1.4f, // Increase line spacing for readability.
WidthF = 200
};
row.Cells.Add(cell);
}
table.Rows.Add(row);
table.EndInit();
// Add the table to the report.
detail.Controls.Add(table);
// Preview the report.
ReportPrintTool tool = new ReportPrintTool(report);
tool.ShowPreviewDialog();
}
}
}
The image below shows the result:
See Also