Back to Devexpress

Localization

windowsforms-401297-controls-and-libraries-gantt-control-localization.md

latest2.0 KB
Original Source

Localization

  • Oct 01, 2019

You can use the GanttLocalizer class to localize captions and date-time formats in the Gantt control. Use the GanttStringId enumeration to identify a caption or a date-time format. See Localizing WinForms Controls with Localizer Objects for more information.

The code below shows how to localize the date-time format for days in the timescale ruler and captions for commands in a Ribbon control.

csharp
using DevExpress.XtraGantt.Localization;

GanttLocalizer.Active = new MyGanttLocalizer();

public class MyGanttLocalizer : GanttLocalizer {
    public override string GetLocalizedString(GanttStringId id) {
        switch (id) {
            case GanttStringId.BothPanelsVisibilityCaption: return "Task List and Chart"; break;
            case GanttStringId.DayFormat: return "dddd, d"; break;
            default: return base.GetLocalizedString(id);
        }
    }
}
vb
Imports DevExpress.XtraGantt.Localization

GanttLocalizer.Active = New MyGanttLocalizer()

Public Class MyGanttLocalizer
    Inherits GanttLocalizer

    Public Overrides Function GetLocalizedString(ByVal id As GanttStringId) As String
        Select Case id
            Case GanttStringId.BothPanelsVisibilityCaption
                Return "Task List and Chart"
            Case GanttStringId.DayFormat
                Return "dddd, d"
            Case Else
                Return MyBase.GetLocalizedString(id)
        End Select
    End Function
End Class

Note

You can also use satellite assemblies to localize WinForms controls. See Localizing WinForms Controls with Satellite Resource Assemblies for more information.