Click here to Skip to main content
13,597,186 members
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 26 Apr 2008
Licenced CPOL

Multi Culture Calendar

, 11 Sep 2009
Rate this:
Please Sign up or sign in to vote.
A calendar which supports all types of calendars such as persian(Farsi)-Arabic and English calendars by changing the culture


As you know, after changing the culture, all controls work with the new culture. In this control, you can use several calendars on a page and change the culture for each one.

The important thing is that Microsoft does not support the UI of the Persian calendar. Now you can use it very easily. It is possible to inherit this control from other controls which you want and make your custom controls.

Using the Code

The code is very easy and I override just the render method. Before the rendering and after that, I change the culture and only for Persian, I use Reflection to change the calendar (Shamsi Calendar).

Here is the important function on this control that shows you how it can be made possible using the Persian calendar:

private void ChangeCulture()
DefaultCulture = new System.Globalization.CultureInfo(

switch (SelectedCulture.Name)
case "fa-IR":
System.Globalization.DateTimeFormatInfo info = SelectedCulture.DateTimeFormat;
info.AbbreviatedDayNames = new string[] { "ی", "§", "«", "چ", "پ", "¤", "¬" };
info.DayNames = new string[] { "یک¬ë ى", "§ي¬ë ى", "ﺳﻪ¬ë ى", "چىں©¬ë ى", "پ뤬ë ى",
    "¤êمى", "¬ë ى" };
info.AbbreviatedMonthNames = new string[] { "ه©ي©§یë", "ں©§ï ى¬¢", "¦©§ں§", "¢ï©",
    "ꩧں§", "¬ى©یي©", "êى©", "™ ںë", "™¨©", "§ی", " ىêë", "ں«هë§", "" };
info.MonthNames = new string[] 
    { "ه©ي©§یë", "ں©§ï ى¬¢", "¦©§ں§", "¢ï©", "ꩧں§", "¬ى©یي©", 
    "êى©", "™ ںë", "™¨©", "§ی", " ىêë", "ں«هë§", "" };
info.AMDesignator = "ç.â";
info.PMDesignator = " .â";
info.ShortDatePattern = "yyyy/MM/dd";
info.FirstDayOfWeek = DayOfWeek.Saturday;
System.Globalization.PersianCalendar cal = new System.Globalization.PersianCalendar();
    "calendar", System.Reflection.BindingFlags.Public |
    System.Reflection.BindingFlags.Instance |
    System.Reflection.BindingFlags.NonPublic).SetValue(info, cal);

object obj = typeof(System.Globalization.DateTimeFormatInfo).GetField(
    "m_cultureTableRecord", System.Reflection.BindingFlags.Public |
    System.Reflection.BindingFlags.Instance |

   System.Reflection.BindingFlags.NonPublic |
   new object[] { cal.GetType().GetProperty("ID",
   System.Reflection.BindingFlags.Instance |
   System.Reflection.BindingFlags.NonPublic).GetValue(cal, null) });

    System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance |
    System.Reflection.BindingFlags.NonPublic).SetValue(SelectedCulture, cal);

System.Threading.Thread.CurrentThread.CurrentCulture = SelectedCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = SelectedCulture;
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat = info;
System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat = info;

System.Threading.Thread.CurrentThread.CurrentCulture = SelectedCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = SelectedCulture;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) Morhipo
Turkey Turkey
System Architect and software developer. Designing and developing infrastructures and frameworks using for win and web base solutions.
I have more than 10 years work experience in developing and designing.

You may also be interested in...

Comments and Discussions

GeneralI don't know how it works! Pin
clickmeplz115-Apr-11 20:13
memberclickmeplz115-Apr-11 20:13 
GeneralRe: I don't know how it works! Pin
Farshid300316-Apr-11 22:57
memberFarshid300316-Apr-11 22:57 
Generalhi farshid3003 Pin
Alishafaat3-Sep-10 9:39
memberAlishafaat3-Sep-10 9:39 
GeneralRe: hi farshid3003 Pin
Farshid300316-Apr-11 23:00
memberFarshid300316-Apr-11 23:00 
GeneralCode access security Pin
arash.rohani25-Jun-10 5:08
memberarash.rohani25-Jun-10 5:08 
GeneralRe: Code access security Pin
Farshid300325-Jun-10 8:25
memberFarshid300325-Jun-10 8:25 
GeneralRe: Code access security Pin
arash.rohani25-Jun-10 9:48
memberarash.rohani25-Jun-10 9:48 
GeneralRe: Code access security Pin
Farshid300329-Jun-10 5:18
memberFarshid300329-Jun-10 5:18 
Generalit coulden't work with janus Pin
amin_ramin888610-Aug-08 5:15
memberamin_ramin888610-Aug-08 5:15 
GeneralRe: it coulden't work with janus Pin
Farshid300311-Sep-09 5:12
memberFarshid300311-Sep-09 5:12 
GeneralArticle seems incomplete Pin
Rob Graham26-Apr-08 11:05
memberRob Graham26-Apr-08 11:05 
GeneralRe: Article seems incomplete Pin
Farshid300311-Sep-09 5:16
memberFarshid300311-Sep-09 5:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.180621.3 | Last Updated 11 Sep 2009
Article Copyright 2008 by Farshid3003
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid