We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

MonthCalendarAdv Culture

Hi,

we know that .Net 3.5 has Persian-Calendar with Solar-calendar type. but when i set the CultureInfo of MonthCalendarAdv in "fa-IR" the calendar view is in Georgine-calendar. i want to know if is a way to use the Persian-Calendar instead of Georgine-calendar in MonthCalendarAdv.

thanks :)

7 Replies

MJ Mano J Syncfusion Team September 21, 2009 04:52 AM UTC

Hi,

You cannot display a persian calendar in MonthCalendarAdv, but can get the persian date using PersianCalendar class.

private void monthCalendarAdv1_SelectionChanged(object sender, EventArgs e)
{
PersianCalendar jc = new PersianCalendar();
DateTime thisDate = this.monthCalendarAdv.SelectedDates[0];
Console.WriteLine("Today is:");
Console.WriteLine(" {0:ddd}, {0} in the Gregorian calendar.", thisDate);
Console.WriteLine(" {0}, {1}/{2}/{3} {4}:{5}:{6} in the Persian calendar.",
jc.GetDayOfWeek(thisDate),
jc.GetMonth(thisDate),
jc.GetDayOfMonth(thisDate),
jc.GetYear(thisDate),
jc.GetHour(thisDate),
jc.GetMinute(thisDate),
jc.GetSecond(thisDate));
}

Regards,
Mano


MH MHaji September 22, 2009 01:09 PM UTC

Hi
thanks for your reply.
But i want to show this result in month Calendar for each month of Persian-Calendar Like Georgian Calendar. one of my friends find out the answer of this problem. i will post this solution when he agrees too do this.


MJ Mano J Syncfusion Team September 22, 2009 03:03 PM UTC

Hi,

Thanks for the update. Please post your solution, if it works for you, so that it will be helpful for others.

Regards,
Mano


MH MHaji September 29, 2009 08:06 AM UTC

Hi
Sorry for my delay to answer.
I attached an application to show what is my reason in real Persian-calendar. if the program is useful please tell me to post the solution.

thanks :)



real persian calendar_5232de51.rar


MJ Mano J Syncfusion Team September 30, 2009 05:27 AM UTC

Hi,

You can post the solution too.

Thanks,
Mano


MH MHaji September 30, 2009 11:48 AM UTC

Hi

thanks for your attention.

this is the solution :

public void SetPersianCulture()
{
CultureInfo MyCulture = new CultureInfo("fa-IR");
DateTimeFormatInfo info = MyCulture.DateTimeFormat;
info.AbbreviatedDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
info.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
info.AbbreviatedMonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.MonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.ShortestDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
info.AMDesignator = "ق.ظ";
info.PMDesignator = "ب.ظ";
info.ShortDatePattern = "yyyy/MM/dd";
info.FirstDayOfWeek = DayOfWeek.Saturday;
System.Globalization.PersianCalendar cal = new System.Globalization.PersianCalendar();
typeof(System.Globalization.DateTimeFormatInfo).GetField("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).GetValue(info);
obj.GetType().GetMethod("UseCurrentCalendar", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(obj, new object[] { cal.GetType().GetProperty("ID", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(cal, null) });
typeof(System.Globalization.CultureInfo).GetField("calendar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(MyCulture, cal);
typeof(System.Globalization.CultureInfo).GetField("calendar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(MyCulture, cal);
System.Threading.Thread.CurrentThread.CurrentCulture = MyCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = MyCulture;
}

you can use this item for example in Form-load procedure and then enjiy the real Persian-calendar and culture.


MJ Mano J Syncfusion Team October 1, 2009 06:48 AM UTC

Hi,

Thanks for sharing the solution.

Regards,
Mano

Loader.
Live Chat Icon For mobile
Up arrow icon