windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitemdateedit-e3b6495d.md
Allows you to provide custom week day abbreviations.
Namespace : DevExpress.XtraEditors.Repository
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Events")]
public event CustomWeekDayAbbreviationEventHandler CustomWeekDayAbbreviation
<DXCategory("Events")>
Public Event CustomWeekDayAbbreviation As CustomWeekDayAbbreviationEventHandler
The CustomWeekDayAbbreviation event's data class is DevExpress.XtraEditors.Controls.CustomWeekDayAbbreviationEventArgs.
The calendar shows week abbreviations based on the application UI culture. You can specify the abbreviation length using the RepositoryItemDateEdit.WeekDayAbbreviationLength property.
However, if this setting does 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 the 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.
private void dateEdit1_Properties_CustomWeekDayAbbreviation(object sender, CustomWeekDayAbbreviationEventArgs e) {
RepositoryItemDateEdit item = sender as RepositoryItemDateEdit;
if(item == null) return;
DateEdit edit = item.OwnerEdit as DateEdit;
if(edit == null) return;
PopupDateEditForm popup = edit.GetPopupEditForm() as PopupDateEditForm;
if(popup == null) return;
CalendarControl calendar = popup.Calendar;
if(calendar == null) return;
if(e.Day == calendar.DateFormat.DayNames[0]) e.Value = "SUNDAY";
if(e.Day == calendar.DateFormat.DayNames[6]) e.Value = "SATURDAY";
}
Private Sub DateEdit1_Properties_CustomWeekDayAbbreviation(sender As Object, e As CustomWeekDayAbbreviationEventArgs) Handles DateEdit1.Properties.CustomWeekDayAbbreviation
Dim item As RepositoryItemDateEdit = TryCast(sender, RepositoryItemDateEdit)
If item Is Nothing Then
Return
End If
Dim edit As DateEdit = TryCast(item.OwnerEdit, DateEdit)
If edit Is Nothing Then
Return
End If
Dim popup As PopupDateEditForm = TryCast(edit.GetPopupEditForm(), PopupDateEditForm)
If popup Is Nothing Then
Return
End If
Dim calendar As CalendarControl = popup.Calendar
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