This is a migrated thread and some comments may be shown as answers.
DateTimePicker how change the month and week name ?
11 Answers 75 Views
This is a migrated thread and some comments may be shown as answers.
Qakmak
Top achievements
Rank 1
Qakmak asked on 08 May 2013, 02:55 PM
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?

11 Answers, 1 is accepted

Sort by
0
Qakmak
Top achievements
Rank 1
answered on 11 May 2013, 09:09 AM
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.
0
Accepted
Ivan Petrov
Telerik team
answered on 13 May 2013, 12:26 PM
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?
0
Qakmak
Top achievements
Rank 1
answered on 13 May 2013, 04:34 PM
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.
0
Ivan Petrov
Telerik team
answered on 16 May 2013, 12:58 PM
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?
0
Qakmak
Top achievements
Rank 1
answered on 17 May 2013, 04:07 AM
Thanks, It can be work. and I think if can use visual style builder change that would be better.
0
Ivan Petrov
Telerik team
answered on 21 May 2013, 02:28 PM
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?
0
Qakmak
Top achievements
Rank 1
answered on 21 May 2013, 05:43 PM
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)
0
Ivan Petrov
Telerik team
answered on 24 May 2013, 10:50 AM
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?
0
Qakmak
Top achievements
Rank 1
answered on 07 Jun 2013, 01:30 PM
Sorry, I can't find it.
0
Ivan Petrov
Telerik team
answered on 12 Jun 2013, 03:30 PM
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?
0
Qakmak
Top achievements
Rank 1
answered on 13 Jun 2013, 01:11 PM
Thanks a lot.
Asked by
Qakmak
Top achievements
Rank 1
Answers by
Qakmak
Top achievements
Rank 1
Ivan Petrov
Telerik team
Share this question
or