Skip to main content

XRLabel.TextFormatString Property

Specifies the output format for a value bound to the label.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.2.dll

NuGet Package: DevExpress.Reporting.Core


public override string TextFormatString { get; set; }

Property Value

Type Description

The output format for a value bound to the label.


The TextFormatString property allows you to specify an output format for values bound to the XRLabel‘s Text property.


Ensure the specified format string fits the type of the bound value. For instance, in the code example below the expression Phone: {0:(###)-##-##} expects the phone field to be an integer. This expression does not work for other types, for example for strings. Refer to the following article for more details on formatting: Format types in .NET.


The following code example shows how to specify the TextFormatString property for the XRLabel control.


Refer to the following help topic for information on how to format data at design time: Format Data.

using DevExpress.XtraReports.UI;
using DevExpress.DataAccess.Json;
// ...
string json = "{\"users\":[{\"name\":\"John\",\"phone\":3335588},{\"name\":\"Ann\",\"phone\":4445577}]}";

// Create a label.
XRLabel label = new XRLabel() {
    WidthF = 120,
    // Specify an expression for the label's "Text" property.
    ExpressionBindings = { new ExpressionBinding("BeforePrint", "Text", "[phone]") },
    // Specify a format string for the label's text.
    TextFormatString = "Phone: {0:(###)-##-##}"

// Create a report with the label.
XtraReport report = new XtraReport() {
    Bands = {
        new DetailBand() {
            HeightF = 25,
            Controls = {label}
    DataSource = new JsonDataSource() {
        JsonSource = new CustomJsonSource(json)
    DataMember = "users"

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the TextFormatString property.


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.

See Also