Back to Devexpress

XtraReport.ApplyLocalization(String) Method

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-dot-applylocalization-x28-system-dot-string-x29.md

latest4.0 KB
Original Source

XtraReport.ApplyLocalization(String) Method

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

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public void ApplyLocalization(
    string culture
)
vb
Public Sub ApplyLocalization(
    culture As String
)

Parameters

NameTypeDescription
cultureString

A culture name. Use a specific culture (e.g., en-US) to maintain currency, number and date format consistency.

|

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.

Note

Use a specific culture (e.g., de-CH) as the method parameter. If you specify a neutral culture (a two-letter lowercase language code), the currency, date and number formats are also set for the neutral culture (which is not what you expect to see).

How to Use the Method

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

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

localizedReport.ApplyLocalization("de-DE");

localizedReport.CreateDocument();

// The document is in German
vb
Imports System.Windows.Forms
Imports DevExpress.XtraReports.UI
Imports System.Threading
' ...
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
Dim localizedReport As XtraReport = New LocalizedReport1()

localizedReport.ApplyLocalization("de-DE")

localizedReport.CreateDocument() 

' The document is in German

Note

If you call the ApplyLocalization method after the CreateDocument method, the document that was already created 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 to be applied to the new document:

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

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

localizedReport.CreateDocument();

// The document is in German
vb
Imports DevExpress.XtraReports.UI
Imports System.Threading
' ...
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
Dim localizedReport As XtraReport = New LocalizedReport1()

AddHandler localizedReport.BeforePrint, Sub(s, e)
  localizedReport.ApplyLocalization("de-DE")
End Sub

localizedReport.CreateDocument()

' The document is in German

Method Specifics

  • Report Parameters

  • Culture-Specific Format Strings

See Also

XtraReport Class

XtraReport Members

DevExpress.XtraReports.UI Namespace