DateTimePicker how change the month and week name ?

12 posts, 1 answers
  1. Qakmak
    Qakmak avatar
    20 posts
    Member since:
    Apr 2013

    Posted 08 May 2013 Link to this post

    I want to change the month name and week name, for Localization.

    but I can't use Culture feature. because that language not in microsoft CultureInfo.

    so I need Custom change the name value .

    How can I do?
  2. Qakmak
    Qakmak avatar
    20 posts
    Member since:
    Apr 2013

    Posted 11 May 2013 Link to this post

    before I'm using one component can doing this. like:

    //set the months name
    this.dtpTime.FormatProvider.MonthNames = new[] { "one", "two", "three", "4", "5", "6", "7", "8", "9", "10", "11", "12", "" };
    //set the weeks short name
    //this.dtpTime.FormatProvider.ShortestDayNames = new[] { "ي", "د", "س", "چ", "پ", "ج", "ش" };


    use this can change the weeks and months name. 
    This can be set independently It, Does not depend on CultureInfo.


    Or better way is can implement some localization interface in your api.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 13 May 2013 Link to this post

    Hi Qakmak,

    Thank you for writing.

    RadDateTimePicker uses a CultureInfo object to localize the dates it displays. The same applies for the RadCalendar that the date time picker hosts. You can create a custom culture info with your desired day and month names and use it in the RadDateTimePicker. Here is an example:
    try
    {
        CultureInfo c = new CultureInfo("my-MY");
        CultureAndRegionInfoBuilder.Unregister("my-MY");
    }
    catch { }
     
    RadDateTimePickerCalendar calendar = this.radDateTimePicker1.DateTimePickerElement.CurrentBehavior as RadDateTimePickerCalendar;
    CultureAndRegionInfoBuilder buidler = new CultureAndRegionInfoBuilder("my-MY", CultureAndRegionModifiers.None);
    buidler.LoadDataFromCultureInfo(calendar.Calendar.Culture);
    buidler.LoadDataFromRegionInfo(new RegionInfo(calendar.Calendar.Culture.Name));
    buidler.GregorianDateTimeFormat.DayNames = new string[] { "ي", "د", "س", "چ", "پ", "ج", "ش" };
    buidler.GregorianDateTimeFormat.MonthNames = new string[] { "J1", "F2", "M3", "A4", "M5", "J6", "J7", "A8", "S9", "O10", "N11", "D12", "" };
    buidler.GregorianDateTimeFormat.MonthGenitiveNames = new string[] { "J1", "F2", "M3", "A4", "M5", "J6", "J7", "A8", "S9", "O10", "N11", "D12", "" };
    buidler.Register();
     
    calendar.Calendar.DayNameFormat = DayNameFormat.Full;  
    this.radDateTimePicker1.Culture = new CultureInfo("my-MY");

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Greetings,
    Ivan Petrov
    the Telerik team
    RadChart for WinForms is obsolete. Now what?
  5. Qakmak
    Qakmak avatar
    20 posts
    Member since:
    Apr 2013

    Posted 13 May 2013 Link to this post

    It's a good way, thanks . but I changed the DateTimePicker Font(use my own font), and the week font not change....only the datetimepicker textbox font is changed.
  6. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 16 May 2013 Link to this post

    Hi Qakmak,

    Thank you for writing back.

    To change the font of the week cells in the calendar you will have to access them individually. Continuing from the code in my previous post you can add the following to achieve your goal:
    foreach (CalendarCellElement cell in ((MonthViewElement)calendar.Calendar.CalendarElement.Children[0].Children[2]).TableElement.Children)
    {
        if (!int.TryParse(cell.Text, out outint))
        {
            cell.Font = new Font(this.radDateTimePicker1.Font.FontFamily, 12);
        }
    }

    I hope this will help. Do not hesitate to write back with further questions.

    Greetings,
    Ivan Petrov
    the Telerik team
    RadChart for WinForms is obsolete. Now what?
  7. Qakmak
    Qakmak avatar
    20 posts
    Member since:
    Apr 2013

    Posted 16 May 2013 Link to this post

    Thanks, It can be work. and I think if can use visual style builder change that would be better.
  8. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 21 May 2013 Link to this post

    Hello Qakmak,

    Thank you for writing back.

    Please find attached a screenshot which illustrates what you have to do to apply a font to the cells you want. You have to apply the font repository to the CalendarCellElement.Header state (green indicators). If you do not have this state you can add it (blue indicators on the image). 

    I hope this helps. Feel free to write back with any further questions.

    Greetings,
    Ivan Petrov
    the Telerik team
    RadChart for WinForms is obsolete. Now what?
  9. Qakmak
    Qakmak avatar
    20 posts
    Member since:
    Apr 2013

    Posted 21 May 2013 Link to this post

    Thanks, It can be work, but the only problem is , when changed the font and font size, I cant change it padding or margin.because my font have some little problem, you can look this:
    http://www.telerik.com/community/forums/winforms/forms-and-dialogs/how-change-the-font-padding-of-form.aspx

    and when I'm changed the Calendar font and font size, that's like this:(look the picture)
  10. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 24 May 2013 Link to this post

    Hello Qakmak,

    Thank you for writing back.

    You can use the HeaderHeight property to increase the height of the header row of RadCalendar. This will give your font more space to draw.

    I hope this will be useful. Feel free to write back.

    Regards,
    Ivan Petrov
    Telerik
    RadChart for WinForms is obsolete. Now what?
  11. Qakmak
    Qakmak avatar
    20 posts
    Member since:
    Apr 2013

    Posted 07 Jun 2013 Link to this post

    Sorry, I can't find it.
  12. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 12 Jun 2013 Link to this post

    Hello Qakmak,

    Thank you for writing back.

    The property is accessible directly from RadControl you should be able to locate it inside the property grid of the Visual Studio designer. I have attached a screenshot of the property set in my machine.

    I hope this will be helpful. Should you need further assistance, I would be glad to provide it.

    Regards,
    Ivan Petrov
    Telerik
    RadChart for WinForms is obsolete. Now what?
  13. Qakmak
    Qakmak avatar
    20 posts
    Member since:
    Apr 2013

    Posted 13 Jun 2013 Link to this post

    Thanks a lot.
Back to Top
UI for WinForms is Visual Studio 2017 Ready