The requested page is not available for the requested platform. You are viewing the content for Default platform.

XRLabel Class

Displays plain text in a report.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.2.dll

Declaration

[ToolboxTabName("DX.18.2: Report Controls")]
[XRDesigner("DevExpress.XtraReports.Design.XRLabelDesigner,DevExpress.XtraReports.v18.2.Extensions, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")]
[DefaultBindableProperty("Text")]
[ToolboxBitmap(typeof(XRLabel))]
[XRToolboxSubcategory(0, 0)]
[ToolboxBitmap24("DevExpress.XtraReports.Images.Toolbox24x24.XRLabel.png,DevExpress.XtraReports.v18.2.Extensions, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")]
[ToolboxBitmap32("DevExpress.XtraReports.Images.Toolbox32x32.XRLabel.png,DevExpress.XtraReports.v18.2.Extensions, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")]
[ToolboxSvgImage("DevExpress.XtraReports.SvgImages.Controls.XRLabel.svg,DevExpress.XtraReports.v18.2.Extensions, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")]
public class XRLabel :
    XRFieldEmbeddableControl,
    IEditOptionsContainer
<ToolboxTabName("DX.18.2: Report Controls")>
<XRDesigner("DevExpress.XtraReports.Design.XRLabelDesigner,DevExpress.XtraReports.v18.2.Extensions, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")>
<DefaultBindableProperty("Text")>
<ToolboxBitmap(GetType(XRLabel))>
<XRToolboxSubcategory(0, 0)>
<ToolboxBitmap24("DevExpress.XtraReports.Images.Toolbox24x24.XRLabel.png,DevExpress.XtraReports.v18.2.Extensions, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")>
<ToolboxBitmap32("DevExpress.XtraReports.Images.Toolbox32x32.XRLabel.png,DevExpress.XtraReports.v18.2.Extensions, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")>
<ToolboxSvgImage("DevExpress.XtraReports.SvgImages.Controls.XRLabel.svg,DevExpress.XtraReports.v18.2.Extensions, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")>
Public Class XRLabel
    Inherits XRFieldEmbeddableControl
    Implements IEditOptionsContainer

Remarks

You can add this control by dragging the XRLabel item from the DX:18.2: Report Controls Toolbox tab onto the report.

report-control-label-0

Use the XRControl.Text property to specify the label's text. You can double-click the label to invoke its in-place editor and type the desired text.

xrlabel-inplace-editor

You can bind the label's Text property to a data field obtained from a report's data source. Click the control's smart tag, expand the Expression drop-down list and select the required data field.

report-control-label-3

See the Label topic for more information.

Examples

This example demonstrates how to create an XRLabel object, bind it to data and specify some of its properties. You should bind your report to the Products table of the Northwind database for this example to work properly.

To learn about the events available for a report and its controls, see Report Events.

using System;
using System.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...

public partial class XtraReport1 : XtraReport {

    public XRLabel CreateXRLabel() {
        // Create a new label object.
        XRLabel label = new XRLabel();

        // Bind the label to the UnitPrice data field. 
        // Change the label's foreground color depending on the UnitPrice data field value.
        label.ExpressionBindings.AddRange(new ExpressionBinding[] {
        new ExpressionBinding("BeforePrint", "Text", "[UnitPrice]"),
        new ExpressionBinding("BeforePrint", "ForeColor", "Iif([UnitPrice]>20, \'Red\', \'Green\')")});

        // Apply a currency format to the label's text.
        label.TextFormatString = "{0:c2}";

        // Automatically adjust the label's width to its content.
        label.AutoWidth = true;

        // Align the label's text to the bottom right corner.
        label.TextAlignment = TextAlignment.BottomRight;

        return label;
    }

    public XtraReport1() {
        // ...
        // Add the label to the report's Detail band.
        XRLabel label = CreateXRLabel();
        this.Detail.Controls.Add(label);
    }
}

Implements

DevExpress.XtraReports.Serialization.IXRSerializable
DevExpress.Utils.Serializing.Helpers.IXtraSupportDeserializeCollectionItem
DevExpress.Utils.Serializing.IXtraSerializable
DevExpress.XtraReports.Native.IDisplayNamePropertyContainer
DevExpress.XtraReports.Native.IEditOptionsContainer
See Also