The Calendar controls such as CalendarView and DateEdit allow you to change regional settings to display the calendar UI in specific locales or languages and set right-to-let support.
Let's explore culture settings and right-to-left support in detail using the Calendar controls.
CalendarView supports built-in globalization to use it in different languages and cultures in the following ways:
The following image shows CalendarView with the French culture applied.
The following code snippet shows how to set the current culture in CalendarView.
C# |
Copy Code
|
---|---|
// Set desired culture, for example here the French (France) locale. calendarView.CurrentCulture = new System.Globalization.CultureInfo("fr-FR"); |
The following GIF displays CalendarView in the Right-to-Left layout.
The following code snippet shows how to set the RightToLeftLayout and the RightToLeft properties in CalendarView.
C# |
Copy Code
|
---|---|
// Enable the Right to Left Layout calendarView.RightToLeftLayout = true; // set the RightToLeft property calendarView.RightToLeft = RightToLeft.Yes; |
DateEdit supports built-in globalization to use it in different languages and cultures in the following ways:
The following image shows DateEdit with Arabic culture in right-to-left direction.
The following code snippet shows how to set the current culture and enable right-to-left functionality in the DateEdit control.
C# |
Copy Code
|
---|---|
// set the culture dateEdit.CultureInfo = new System.Globalization.CultureInfo("ar-IQ"); // enable right to left functionality dateEdit.RightToLeft = RightToLeft.Yes; dateEdit.Calendar.DayNameLength = 4; |
You can also set the DateEdit with Japanese culture:
The following code snippet shows how to set the Japanese culture in the DateEdit control:
C# |
Copy Code
|
---|---|
dateEdit.CultureInfo = new System.Globalization.CultureInfo("ja-JP"); dateEdit.Calendar.CalendarType = C1.Win.Calendar.CalendarType.JapaneseCalendar; dateEdit.Calendar.CaptionFormat = "gg yyyy年 MM"; |