All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

XtraReport.ApplyLocalization(CultureInfo) Method

Applies values contained in the localized report for the specified culture.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v21.1.dll

Declaration

public void ApplyLocalization(
    CultureInfo culture
)

Parameters

Name Type Description
culture CultureInfo

A CultureInfo object that specifies the .NET culture. The ApplyLocalization method uses only the culture’s language code.

Remarks

The method is used for localized reports and allows you to create a document in the locale that differs from the current thread culture.

How to Use the Method

Call the method before the XtraReport.CreateDocument method to specify the language applied to the created document.

using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using System.Threading;
// ...
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
XtraReport localizedReport = new LocalizedReport1();

localizedReport.ApplyLocalization(new CultureInfo("de-DE"));

localizedReport.CreateDocument();

// The document is in German

Note

If you call the ApplyLocalization method after the CreateDocument method, the already created document retains its language. In this case the ApplyLocalization method has no effect.

As an alternative, you may call the ApplyLocalization method in the BeforePrint handler to specify the language applied to the created document:

using DevExpress.XtraReports.UI;
using System.Threading;
// ...
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
XtraReport localizedReport = new LocalizedReport1();

localizedReport.BeforePrint += (s, e) =>
{
    localizedReport.ApplyLocalization(new CultureInfo("de-DE"));
};

localizedReport.CreateDocument();

// The document is in German

Method Specifics

  • Report Parameters

    If you call the ApplyLocalization method in the BeforePrint event, the Parameter.Description property value changes, but the text displayed in the Parameters Panel does not. The Parameters Panel is initialized before the report’s events, so you should call the ApplyLocalization method before the XtraReport.CreateDocument method to change the Parameters Panel text.

  • Culture-Specific Format Strings

    Report controls use the TextFormatString property to display non-static content. The TextFormatString property is localizable and can be set to different strings for different report languages. However, certain format strings are culture-specific and the resulting text is determined by the current thread’s culture.

    The ApplyLocalization method changes the current thread’s culture. The CreateDocument method uses the current thread’s culture to resolve culture-sensitive formatting strings.

    The following code snippet demonstrates how the ApplyLocalization method changes the XRPageInfo control’s text.

    using DevExpress.XtraReports.UI;
    // ...
      Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
      XtraReport localizedReport = new LocalizedReport1();
      XRPageInfo pageInfoControl = localizedReport.AllControls<XRPageInfo>().FirstOrDefault();
      if (pageInfoControl != null)
      {
        pageInfoControl.PageInfo = DevExpress.XtraPrinting.PageInfo.DateTime;
        pageInfoControl.TextFormatString = "D";
      }
      localizedReport.CreateDocument();
      // Displays "Monday, April 20, 2020"
      localizedReport.ApplyLocalization(new CultureInfo("fr-FR"));
      localizedReport.CreateDocument();
      // Displays "lundi 20 avril 2020"
    
See Also