Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

XRBarCode.TextFormatString Property

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

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v24.2.dll

NuGet Package: DevExpress.Reporting.Core

#Declaration

[Browsable(true)]
public override string TextFormatString { get; set; }

#Property Value

Type Description
String

The output format for a value bound to the barcode.

#Remarks

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

Note

Ensure that the specified format string fits the type of the bound value. For instance, in the code example below the expression {0:(####)-####} expects the code 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.

#Example

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

Note

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 = "{\"codes\":[{\"code\":12341234},{\"code\":56785678}]}";

// Create a barcode.
XRBarCode barcode = new XRBarCode() {
    HeightF = 150, WidthF = 550,
    TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
    // Specify an expression for the barcode's "Text" property.
    ExpressionBindings = { new ExpressionBinding("BeforePrint", "Text", "[code]") },
    // Specify a format string for the barcode's text.
    TextFormatString = "{0:####-#-###}"
};

// Create a report with the barcode.
XtraReport report = new XtraReport() {
    Bands = {
        new DetailBand() {
            HeightF = 200,
            Controls = {barcode}
        }
    },
    DataSource = new JsonDataSource() {
        JsonSource = new CustomJsonSource(json)
    },
    DataMember = "codes"
};

See Also