Back to Devexpress

CalendarControlBase.CustomWeekDayAbbreviation Event

windowsforms-devexpress-dot-xtraeditors-dot-controls-dot-calendarcontrolbase-59cbf793.md

latest3.6 KB
Original Source

CalendarControlBase.CustomWeekDayAbbreviation Event

Allows you to provide custom week day abbreviations.

Namespace : DevExpress.XtraEditors.Controls

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event CustomWeekDayAbbreviationEventHandler CustomWeekDayAbbreviation
vb
<DXCategory("Events")>
Public Event CustomWeekDayAbbreviation As CustomWeekDayAbbreviationEventHandler

Event Data

The CustomWeekDayAbbreviation event's data class is DevExpress.XtraEditors.Controls.CustomWeekDayAbbreviationEventArgs.

Remarks

The calendar shows week abbreviations based on the application UI culture. You can specify the abbreviation length and type case using the CalendarControlBase.WeekDayAbbreviationLength and CalendarControlBase.CaseWeekDayAbbreviations properties, respectively.

However, if these settings do not meet your needs, you can provide custom week day abbreviations handling the CustomWeekDayAbbreviation event. Use the Day event argument to determine the day of week being processed, and set the Value argument to the required value. The DefaultDayAbbreviation argument gets the value used by default. The code below shows how to provide custom captions for Sunday and Saturday.

csharp
using DevExpress.XtraEditors.Controls;

private void calendarControl1_CustomWeekDayAbbreviation(object sender, DevExpress.XtraEditors.Controls.CustomWeekDayAbbreviationEventArgs e) {
    CalendarControl calendar = sender as CalendarControl;
    if(calendar == null) return;
    if(e.Day == calendar.DateFormat.DayNames[0]) e.Value = "SUNDAY";
    if(e.Day == calendar.DateFormat.DayNames[6]) e.Value = "SATURDAY";
}
vb
Imports DevExpress.XtraEditors.Controls

Private Sub CalendarControl1_CustomWeekDayAbbreviation(sender As Object, e As DevExpress.XtraEditors.Controls.CustomWeekDayAbbreviationEventArgs) Handles CalendarControl1.CustomWeekDayAbbreviation
    Dim calendar As CalendarControl = sender
    If calendar Is Nothing Then
        Return
    End If
    If e.Day = calendar.DateFormat.DayNames(0) Then
        e.Value = "SUNDAY"
    End If
    If e.Day = calendar.DateFormat.DayNames(6) Then
        e.Value = "SATURDAY"
    End If
End Sub

See the result below.

See Also

WeekDayAbbreviationLength

CaseWeekDayAbbreviations

CalendarControlBase Class

CalendarControlBase Members

DevExpress.XtraEditors.Controls Namespace