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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MonthCalendarAdv Culture

Thread ID:

Created:

Updated:

Platform:

Replies:

90160 Sep 18,2009 08:28 PM UTC Oct 1,2009 06:48 AM UTC WinForms 7
loading
Tags: Tools
MHaji
Asked On September 18, 2009 08:28 PM UTC

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 :)

Mano J [Syncfusion]
Replied On 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

MHaji
Replied On 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.

Mano J [Syncfusion]
Replied On 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

MHaji
Replied On 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

Mano J [Syncfusion]
Replied On September 30, 2009 05:27 AM UTC

Hi,

You can post the solution too.

Thanks,
Mano

MHaji
Replied On 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.

Mano J [Syncfusion]
Replied On October 1, 2009 06:48 AM UTC

Hi,

Thanks for sharing the solution.

Regards,
Mano

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;