Back to Devexpress

How to: Modify the Today Caption in the DateNavigator control

windowsforms-5499-controls-and-libraries-scheduler-examples-datenavigator-how-to-modify-the-today-caption-in-the-datenavigator-control.md

latest2.9 KB
Original Source

How to: Modify the Today Caption in the DateNavigator control

  • Feb 07, 2019

To change the Date Navigator‘s Today and Clear button captions, you can use the Localizer approach.

To accomplish this, implement MyDateNavigatorLocalizer class which inherits from the Localizer class and override its Localizer.GetLocalizedString method to return a proper text.

Set the static Localizer.Active property to utilize the MyDateNavigatorLocalizer class. This property should be set before initializing any other control, that is before the InitializeComponent() call.

View Example

csharp
DevExpress.XtraScheduler.Localization.SchedulerLocalizer.Active = new MySchedulerLocalizer();
        DevExpress.XtraEditors.Controls.Localizer.Active = new MyDateNavigatorLocalizer();
public class MyDateNavigatorLocalizer : DevExpress.XtraEditors.Controls.Localizer {
    public override string GetLocalizedString(DevExpress.XtraEditors.Controls.StringId id) {
        if (id == DevExpress.XtraEditors.Controls.StringId.DateEditToday)
            return "Heute";
        if (id == DevExpress.XtraEditors.Controls.StringId.DateEditClear)
            return "Löschen";
        return base.GetLocalizedString(id);
    }
}
vb
Public Class MyDateNavigatorLocalizer
    Inherits DevExpress.XtraEditors.Controls.Localizer

    Public Overrides Function GetLocalizedString(ByVal id As DevExpress.XtraEditors.Controls.StringId) As String
        If id = DevExpress.XtraEditors.Controls.StringId.DateEditToday Then
            Return "Heute"
        End If
        If id = DevExpress.XtraEditors.Controls.StringId.DateEditClear Then
            Return "Löschen"
        End If
        Return MyBase.GetLocalizedString(id)
    End Function
End Class
vb
Partial Friend Class MyApplication
    Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
        DevExpress.XtraScheduler.Localization.SchedulerLocalizer.Active = New MySchedulerLocalizer()
        DevExpress.XtraEditors.Controls.Localizer.Active = New MyDateNavigatorLocalizer()
    End Sub
End Class

See Also

Localization