fa-Ir Culture in RadDateTimePicker problem

13 posts, 0 answers
  1. Arash
    Arash avatar
    22 posts
    Member since:
    Aug 2010

    Posted 26 Oct 2011 Link to this post

    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
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 28 Oct 2011 Link to this post

    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.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Arash
    Arash avatar
    22 posts
    Member since:
    Aug 2010

    Posted 28 Oct 2011 Link to this post

    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?
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 01 Nov 2011 Link to this post

    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.

  6. Arash
    Arash avatar
    22 posts
    Member since:
    Aug 2010

    Posted 02 Nov 2011 Link to this post

    In new release Q2 2011 SP1 this problem hasn't been solved?
  7. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 02 Nov 2011 Link to this post

    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.

  8. Naser
    Naser avatar
    18 posts
    Member since:
    Oct 2012

    Posted 11 May 2012 Link to this post

    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

      
  9. shahab
    shahab avatar
    58 posts
    Member since:
    Mar 2009

    Posted 15 Jul 2013 Link to this post

    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?
  10. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 17 Jul 2013 Link to this post

    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 >>
  11. John
    John avatar
    15 posts
    Member since:
    Nov 2013

    Posted 22 Dec 2013 Link to this post

    Hello support!
    Is this problem solved in new version?
    Thanks
  12. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 23 Dec 2013 Link to this post

    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 >>
  13. John
    John avatar
    15 posts
    Member since:
    Nov 2013

    Posted 23 Dec 2013 Link to this post

    Thanks
    But the screen shot is not persian calendar yet!
    It is Arabic!
    I need to know is it possible to have persian calendar?
  14. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 23 Dec 2013 Link to this post

    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 >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready