This is a migrated thread and some comments may be shown as answers.

fa-Ir Culture in RadDateTimePicker problem

12 Answers 205 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Arash
Top achievements
Rank 1
Arash asked on 26 Oct 2011, 10:46 AM
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:
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: index

I 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: index

Then 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

12 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 28 Oct 2011, 12:50 PM
Hello Arash,

Thank you for writing.

This is a known issue that will be addressed in our upcoming Q3 2011 release. Due to the nature of the issue, I cannot suggest a suitable workaround for it.

Do not hesitate to contact us if you have other questions.

Kind regards,
Peter
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Arash
Top achievements
Rank 1
answered on 28 Oct 2011, 01:52 PM
Hello Peter and thank you for your support, so it hasn't been solved yet in any available versions and I can't do anything for fixing it myself?
0
Peter
Telerik team
answered on 01 Nov 2011, 11:59 AM
Hi Arash,

I am afraid I cannot suggest a workaround for the issue, because the source of the issue is in the order in which the fields are initialized in RadCalendar.

Greetings,
Peter
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Arash
Top achievements
Rank 1
answered on 02 Nov 2011, 04:03 PM
In new release Q2 2011 SP1 this problem hasn't been solved?
0
Nikolay
Telerik team
answered on 02 Nov 2011, 04:13 PM
Hello Arash,

Please re-read the response of my colleague Peter given on Oct 28. As he mentions there, the issue will be addressed in Q3 2011 (expected to be release in mid-November). In other words, the issue is not addressed in Q2 2011 SP1.

I hope that this clarifies the case.

Best wishes,
Nikolay
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Naser
Top achievements
Rank 1
answered on 11 May 2012, 06:52 PM
Hi Arash.
I have a solution for your problem:
1- Go to this address  : http://persianculture.codeplex.com/
2- Set your target framework on .net 4 or 3.5

  
0
shahab
Top achievements
Rank 1
answered on 15 Jul 2013, 05:45 AM
I am using Telerik 2013 with .Net Framework 2.0. The problem is exist. I think it is because of .net framework version. Am I right?
0
Peter
Telerik team
answered on 17 Jul 2013, 02:27 PM
Hello Shabab,

Thank you for contacting us.

I was not able to reproduce the issue using version Q2 2013. Please, refer to the screenshot from my attempts. Please send me a sample project which I can use to reproduce the wrong behavior locally. This will help me investigate the case and provide you with proper support.

In case you have any further questions, do not hesitate to write back.

Regards,
Peter
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
John
Top achievements
Rank 1
answered on 22 Dec 2013, 08:37 AM
Hello support!
Is this problem solved in new version?
Thanks
0
Stefan
Telerik team
answered on 23 Dec 2013, 07:23 AM
Hi John,

Thank you for writing.

The issue is already resolved and you can successfully set the RadDateTimePicker.Culture to "fa-IR", and the control will be localized correctly, without an exception. Please have a look at the attached screen shot.

I hope that you find this information useful.  

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
John
Top achievements
Rank 1
answered on 23 Dec 2013, 08:21 AM
Thanks
But the screen shot is not persian calendar yet!
It is Arabic!
I need to know is it possible to have persian calendar?
0
Stefan
Telerik team
answered on 23 Dec 2013, 08:37 AM
Hi,

Currently, RadCalendar does not support persian calendar. We have a feature request for such in our Public Issue Tracking System. Feel free to add your vote and subscribe for status change alerts here: http://www.telerik.com/support/pits.aspx#/details/Issue=14570.

For the time being, you can only use the Culture property to localize the calendar. 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Arash
Top achievements
Rank 1
Answers by
Peter
Telerik team
Arash
Top achievements
Rank 1
Nikolay
Telerik team
Naser
Top achievements
Rank 1
shahab
Top achievements
Rank 1
John
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or