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

String format to display only years

3 Answers 79 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Avi Avni
Top achievements
Rank 1
Avi Avni asked on 12 Dec 2010, 03:56 PM

Hello

I need to display in the date picker only the years.

I use the Date Selection Mode="Year" but in the text box it Still show the all date.

I try to give string format it not work.

How can I solve this problem?

Best regards

Ehud

 

3 Answers, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 14 Dec 2010, 11:23 AM
Hi Ehud Pinchas,

You have to specify an explicit ShortDatePattern in order to display a custom format string. Follow the posted code:

timePicker.Culture = new System.Globalization.CultureInfo("en-US");
            timePicker.Culture.DateTimeFormat = new System.Globalization.DateTimeFormatInfo
            {
                ShortDatePattern = "yyyy"
            };


All the best,
Kaloyan
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Inge
Top achievements
Rank 1
answered on 19 Mar 2014, 09:19 AM
Hi,

I'm facing the same issue, when I set the above mentioned solution in my code behind, it changes every datepicker on the page, but I need this string format on only one datepicker..
Any suggestions?

Inge
0
Inge
Top achievements
Rank 1
answered on 19 Mar 2014, 09:30 AM
Never mind, the culture is a ref field. So if you pass the current thread culture it will change the notation of the current thread culture and apply it throughout the application.
So if you want to set the same culture as the current thread, use new CultureInfo(Thread.CurrentThread.CurrentCulture.Name)
Tags
DateTimePicker
Asked by
Avi Avni
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Inge
Top achievements
Rank 1
Share this question
or