XtraLocalizer.QueryLocalizedString Event
Allows you to localize resources for all DevExpress UI controls in your application.
Namespace: DevExpress.Utils.Localization
Assembly: DevExpress.Data.v24.2.dll
Declaration
public static event EventHandler<XtraLocalizer.QueryLocalizedStringEventArgs> QueryLocalizedString
Event Data
The QueryLocalizedString event's data class is XtraLocalizer.QueryLocalizedStringEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
ContainerType | Gets the type of a localizer object or data form shipped as part of a DevExpress UI control. |
Culture | Gets the culture name of ResourceStringID. |
InvariantString | Gets the culture-independent (invariant) resource string. |
IsTranslated | Gets whether the resource string is localized (translated) for the current locale (culture). |
ResourceStringID | Gets the value of the enumeration member in StringIDType that corresponds to the processed resource string, or the value that uniquely identifies the form’s UI element/control. |
StringID | Gets the enumeration member in StringIDType that corresponds to the processed resource string. |
StringIDType | Gets the type of the resource string identifier for DevExpress UI controls. |
Value | Gets or sets the resource string. |
The event data class exposes the following methods:
Method | Description |
---|---|
ToString() | Returns a string in the following format: {ResourceStringID}: “{Value}”/“{InvariantString”}. |
Remarks
The QueryLocalizedString
event fires when the control requests a resource string and allows you to translate or modify it as needed.
The e.StringID gets the resource string requested by the control. The e.StringIDType parameter allows you to obtain the type of the control that is requesting the resource string. Use the e.Value parameter to specify the resource string (translated or modified) requested by the control.
using System;
using System.Windows.Forms;
using DevExpress.Utils.Localization;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid.Localization;
namespace DXApplication {
internal static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
XtraLocalizer.QueryLocalizedString += XtraLocalizer_QueryLocalizedString;
Application.Run(new Form1());
}
static private void XtraLocalizer_QueryLocalizedString(object sender, XtraLocalizer.QueryLocalizedStringEventArgs e) {
if (e.StringIDType == typeof(GridStringId)) {
if ((GridStringId)e.StringID == GridStringId.GridGroupPanelText)
e.Value = "Gruppenregion";
}
if (e.StringIDType == typeof(StringId)) {
if ((StringId)e.StringID == StringId.PictureEditMenuCut)
e.Value = "Ausschneiden";
if ((StringId)e.StringID == StringId.PictureEditMenuCopy)
e.Value = "Kopieren";
if ((StringId)e.StringID == StringId.PictureEditMenuPaste)
e.Value = "Einfugen";
}
}
}
}
Note
The QueryLocalizedString
event is a weak event. You should implement the event handler as a method. Otherwise, the garbage collector can collect a reference to your delegate.