[]
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:
Culture settings: CalendarView supports full localization on week title and month title through the System.Globalization Namespace. It includes information pertaining to the culture such as language, country/region, and format patterns for dates, currency, and numbers etc. Specifying locale for the current culture affects the string displayed on the week title and the month title. By default, the current culture designates through the CurrentCulture property of System.Threading.Thread.CurrentThread. To use a culture other than the current culture, set the desired culture by specifying the culture name. For more information about different culture names and identifiers, see CultureInfo class in .NET Framework documentation.
The following image shows CalendarView with the French culture applied.
The following code snippet shows how to set the current culture in CalendarView.
// Set desired culture, for example here the French (France) locale.
calendarView.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");
Right-to-left support: CalendarView supports Right-to-Left functionality for languages that follow Right-to-Left scripts. The control enables you to display calendar in the Right-to-Left direction by using the RightToLeftLayout and the RightToLeft properties. When both RightToLeftLayout and RightToLeft properties are true and Yes respectively, the calendar appears in the Right-to-Left direction.
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.
// 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.
// 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:
dateEdit.CultureInfo = new System.Globalization.CultureInfo("ja-JP");
dateEdit.Calendar.CalendarType = C1.Win.Calendar.CalendarType.JapaneseCalendar;
dateEdit.Calendar.CaptionFormat = "gg yyyy年 MM";