Skip to main content
All docs
V24.2

XtraLocalizer.QueryLocalizedStringContainerResource Event

Allows you to localize resources of data forms integrated in DevExpress UI controls.

Namespace: DevExpress.Utils.Localization

Assembly: DevExpress.Data.v24.2.dll

Declaration

public static event EventHandler<XtraLocalizer.QueryLocalizedStringEventArgs> QueryLocalizedStringContainerResource

Event Data

The QueryLocalizedStringContainerResource 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 QueryLocalizedStringContainerResource event fires when a data form that ships as part of a DevExpress UI control (for example, a BookmarkForm in the WinForms Rich Text Editor) requests a resource string for its UI element (input field, list, button, etc.). Handle the event to translate non-localized resource strings or modify existing resources of form elements.

Use the e.ContainerType event parameter to get the type of the data form. The e.ResourceStringID parameter uniquely identifies the form’s UI element/control that requested the resource string ({ContainerType}.{controlName}.{propertyPath}).

Example

The following example demonstrates how to localize the Location button’s caption into German. This button is displayed on the Bookmark Form that ships as part of the WinForms XtraRichEdit control.

using System;
using System.Windows.Forms;
using System.Globalization;
using System.Threading;
using DevExpress.Utils.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);
            CultureInfo culture = CultureInfo.CreateSpecificCulture("de-DE");
            Thread.CurrentThread.CurrentUICulture = culture;
            Thread.CurrentThread.CurrentCulture = culture;
            // Sets the German culture as the default culture for all threads in the application. 
            CultureInfo.DefaultThreadCurrentCulture = culture;
            CultureInfo.DefaultThreadCurrentUICulture = culture;
            XtraLocalizer.QueryLocalizedStringContainerResource += XtraLocalizer_QueryLocalizedStringContainerResource;
            Application.Run(new Form1());
        }
        private static void XtraLocalizer_QueryLocalizedStringContainerResource(object sender, XtraLocalizer.QueryLocalizedStringEventArgs e) {
            if (e.ContainerType == typeof(DevExpress.XtraRichEdit.Forms.BookmarkForm)) {
                if (e.ResourceStringID == "DevExpress.XtraRichEdit.Forms.BookmarkForm.rgSortBy.Properties.Items3")
                    if (!e.IsTranslated && Thread.CurrentThread.CurrentCulture.Name == "de-DE")
                        e.Value = "&Standort";
            }
        }
    }
}
See Also