0

I have form with more than one RadDatePicker, Every thing work fine but when I want to enter date I want the end user enter date in format dd/mm/yyyy BUT the tool accept only date in format mm/dd/yyyy order!!

Example: 13/12/2016 If the user enter 13 then press spacebar then type 12 then press spacebar 2016 then press enter It gives Error

enter image description here

How can I change the format for entering date?

Thanks in advance.

Abdulsalam Elsharif
  • 4,773
  • 7
  • 32
  • 66
  • Just going by what is in your question, if you want/need a particular format, and the selected tool does not support that format, pick a different tool. Or write your own tool. – Kevin Jan 04 '17 at 21:05
  • @Kevin I'm asking if I can do what I want to do using this tool ! – Abdulsalam Elsharif Jan 04 '17 at 21:19

2 Answers2

1

Try set ShortDatePattern in DateTimeFormatInfo:

CultureInfo cultureInfo = new CultureInfo("en-US");  
DateTimeFormatInfo dateInfo = new DateTimeFormatInfo();  
dateInfo.ShortDatePattern = "dd/MM/yyyy";  
cultureInfo.DateTimeFormat = dateInfo;  
radDatePicker1.Culture = cultureInfo; 

You should also implement custom parsing: http://docs.telerik.com/devtools/wpf/controls/raddatetimepicker/how-to/implement-custom-parsing

Example:

private void radDateTimePicker_ParseDateTimeValue(object sender, Telerik.Windows.Controls.ParseDateTimeEventArgs args)
{
    DateTime date;
    string input = args.TextToParse.ToLower();
    CultureInfo provider = CultureInfo.InvariantCulture;
    string format = "dd/MM/yyyy";
    if (DateTime.TryParseExact(input, format, provider, DateTimeStyles.None, out date))
    {
        args.Result = date;
    }
    else
    {
        args.IsParsingSuccessful = false;
    }
}
kmatyaszek
  • 19,016
  • 9
  • 60
  • 65
0

Finally, I solved the issue by changing the culture from "en-US" to "ar-LY"

<telerik:RadDatePicker Culture="ar-LY"/>

Also, You can check .NET Framework Cultures with Date and Time String Formats

Hope this help.

Abdulsalam Elsharif
  • 4,773
  • 7
  • 32
  • 66