hello,
I am using Q2 2011 and want to have a Persian DateTimePicker but when I set RadDateTimePicker culture property to fa-Ir, an exception is thrown in this line:
I tried everything said in other forum threads like setting thread culture and calendar to persian :
but I get the same exception at this line:
Then I tried another code posted in MSDN forums:
the same exception is thrown again in this line:
I couldn't find anyhting on the net and I'm stuck with a Persian Date picker!
please help me
I am using Q2 2011 and want to have a Persian DateTimePicker but when I set RadDateTimePicker culture property to fa-Ir, an exception is thrown in this line:
this.radDateTimePicker1.Culture = new System.Globalization.CultureInfo("fa-IR");Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: indexI tried everything said in other forum threads like setting thread culture and calendar to persian :
CultureInfo info = new CultureInfo("fa-Ir");info.DateTimeFormat.Calendar = new PersianCalendar();Thread.CurrentThread.CurrentCulture = info;this.radDateTimePicker1.Culture = info;but I get the same exception at this line:
this.radDateTimePicker1.Culture = info;Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: indexThen I tried another code posted in MSDN forums:
System.Globalization.CultureInfo calture = new System.Globalization.CultureInfo("fa-IR");System.Globalization.DateTimeFormatInfo info = calture.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();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(calture, cal);typeof(System.Globalization.CultureInfo).GetField("calendar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(calture, cal);System.Threading.Thread.CurrentThread.CurrentCulture = calture;System.Threading.Thread.CurrentThread.CurrentUICulture = calture;System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat = info;System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat = info;the same exception is thrown again in this line:
this.radDateTimePicker1 = new Telerik.WinControls.UI.RadDateTimePicker();System.ArgumentOutOfRangeException was unhandled Message=Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index Source=mscorlib ParamName=index StackTrace: at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.ThrowHelper.ThrowArgumentOutOfRangeException() at System.Collections.Generic.List`1.get_Item(Int32 index) at Telerik.WinControls.UI.MaskDateTimeProvider.SelectFirstItem() at Telerik.WinControls.UI.MaskDateTimeProvider.SelectFirstEditableItem() at Telerik.WinControls.UI.MaskDateTimeProvider..ctor(String mask, CultureInfo culture, RadMaskedEditBoxElement owner) at Telerik.WinControls.UI.RadMaskedEditBoxElement.CreateMaskProvider() at Telerik.WinControls.UI.RadMaskedEditBoxElement.set_Mask(String value) at Telerik.WinControls.UI.RadDateTimePickerCalendar.SetDateByValue(Nullable`1 date, DateTimePickerFormat formatType) at Telerik.WinControls.UI.RadDateTimePickerCalendar.CreateChildren() at Telerik.WinControls.UI.RadDateTimePickerElement.SetBehavior(RadDateTimePickerBehaviorDirector childrenDirector) at Telerik.WinControls.UI.RadDateTimePickerElement.CreateChildElements() at Telerik.WinControls.RadElement.CallCreateChildElements() at Telerik.WinControls.RadElement.Construct() at Telerik.WinControls.RadElement..ctor() at Telerik.WinControls.RadItem..ctor() at Telerik.WinControls.UI.RadDateTimePickerElement..ctor() at Telerik.WinControls.UI.RadDateTimePicker.CreateChildItems(RadElement parent) at Telerik.WinControls.RadControl.Telerik.WinControls.IComponentTreeHandler.CreateChildItems(RadElement parent) at Telerik.WinControls.RadControl.ComponentOverrideElementTree.CreateChildItems(RadElement parent) at Telerik.WinControls.RadControl.Construct() at Telerik.WinControls.RadControl..ctor() at Telerik.WinControls.UI.RadDateTimePicker..ctor() at test.Form1.InitializeComponent() in C:\Users\Arash\Desktop\New folder\test\test\Form1.Designer.cs:line 32 at test.Form1..ctor() in C:\Users\Arash\Desktop\New folder\test\test\Form1.cs:line 43 at test.Program.Main() in C:\Users\Arash\Desktop\New folder\test\test\Program.cs:line 18 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: I couldn't find anyhting on the net and I'm stuck with a Persian Date picker!
please help me
