Back to Devexpress

XRLabel.LineSpacing Property

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrlabel-295d0689.md

latest8.1 KB
Original Source

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.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
[DefaultValue(1F)]
[SRCategory(ReportStringId.CatLayout)]
public virtual float LineSpacing { get; set; }
vb
<DefaultValue(1F)>
<SRCategory(ReportStringId.CatLayout)>
Public Overridable Property LineSpacing As Single

Property Value

TypeDefaultDescription
Single1

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:

csharp
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();
        }
    }
}
vb
Imports DevExpress.XtraReports.UI
Imports System
Imports System.Drawing

Namespace DXApplication
    Public Partial Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

        Public Sub New()
            InitializeComponent()
            AddHandler Me.Load, AddressOf Form1_Load
        End Sub

        Private Sub Form1_Load(sender As Object, e As EventArgs)
            Dim report As New XtraReport()

            ' Create a Detail band.
            Dim detail As New DetailBand()
            report.Bands.Add(detail)

            ' Create a label and set its properties.
            Dim label As New XRLabel() With {
                .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.
            Dim tool As New ReportPrintTool(report)
            tool.ShowPreviewDialog()
        End Sub
    End Class
End Namespace

The image below shows the result:

Example - XRTableCell

csharp
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();
        }
    }
}
vb
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraPrinting
Imports System

Namespace DXApplication
    Public Partial Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

        Public Sub New()
            InitializeComponent()
            AddHandler Me.Load, AddressOf Form1_Load
        End Sub

        Private Sub Form1_Load(sender As Object, e As EventArgs)
            Dim report As New XtraReport()

            ' Create a Detail band.
            Dim detail As New DetailBand()
            report.Bands.Add(detail)

            ' Create a table.
            Dim table As New XRTable()
            table.BeginInit()
            table.WidthF = 600
            table.Padding = New PaddingInfo(40, 0, 40, 0)
            Dim row As New XRTableRow()

            ' Sample long text
            Dim sampleText As String =
                "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 i As Integer = 0 To 2
                Dim cell As New XRTableCell() With {
                    .Text = sampleText,
                    .LineSpacing = 1.4F, ' Increase line spacing for readability.
                    .WidthF = 200
                }
                row.Cells.Add(cell)
            Next

            table.Rows.Add(row)
            table.EndInit()

            ' Add the table to the report.
            detail.Controls.Add(table)

            ' Preview the report.
            Dim tool As New ReportPrintTool(report)
            tool.ShowPreviewDialog()
        End Sub
    End Class
End Namespace

The image below shows the result:

See Also

XRLabel Class

XRLabel Members

DevExpress.XtraReports.UI Namespace