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.v22.1.dll


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"

See Also