7 Answers, 1 is accepted
Hi Gert,
Thank you for the provided images.
One idea that comes to mind is to set both the Short and Long date and time patterns of the picker's Culture and set the DisplayFormat property to use the Long format. As the RadDateTimePicker will use the Short patterns for the input, this should provide the desired result.
Here's what I have in mind:
this.radDateTimePicker.Culture = new System.Globalization.CultureInfo("en-US");
this.radDateTimePicker.Culture.DateTimeFormat.ShortDatePattern = "ddMMyy";
this.radDateTimePicker.Culture.DateTimeFormat.ShortTimePattern = "HHmm";
this.radDateTimePicker.Culture.DateTimeFormat.LongDatePattern = "dd.MM.yyyy";
this.radDateTimePicker.Culture.DateTimeFormat.LongTimePattern = "";
<telerik:RadDateTimePicker x:Name="radDateTimePicker" DisplayFormat="Long" />
Could you please have and let me know if such an approach would work for you? I will be awaiting your reply.
Regards,
Dilyan Traykov
Progress Telerik

Hi Dilyan,
this is working perfect for me for RadDatePicker as a stand alone control, but how can I achive the same behavior in my derived GridViewDateColumn? In this case I do not need the Preview Tooltip. (girdDate1.jpg)
public class FWDateColumn : GridViewDataColumn
{
public FWDateColumn()
{
Style editorStyle = new Style(typeof(RadDatePicker));
Setter setter = new Setter(DataGridRow.PaddingProperty, new Thickness(0));
editorStyle.Setters.Add(setter);
Setter setter2 = new Setter(DataGridRow.VerticalAlignmentProperty, VerticalAlignment.Center);
editorStyle.Setters.Add(setter2);
editorStyle.BasedOn = (Style)FindResource(typeof(RadDatePicker));
EditorStyle = editorStyle;
}
...
}
Thank you very much for your great support.
BR Gert
Hi Gert,
To achieve this in the context of the RadGridView control, you can override the CreateCellEditElement method like so:
public class FWDateColumn : GridViewDataColumn
{
// ...
public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem)
{
var editor = base.CreateCellEditElement(cell, dataItem) as RadDateTimePicker;
editor.Culture = new System.Globalization.CultureInfo("en-US");
editor.Culture.DateTimeFormat.ShortDatePattern = "ddMMyy";
editor.Culture.DateTimeFormat.ShortTimePattern = "HHmm";
editor.Culture.DateTimeFormat.LongDatePattern = "dd.MM.yyyy";
editor.Culture.DateTimeFormat.LongTimePattern = "";
editor.DisplayFormat = DateTimePickerFormat.Long;
return editor;
}
}
private void GridView_PreparedCellForEdit(object sender, GridViewPreparingCellForEditEventArgs e)
{
var editor = e.EditingElement as RadDateTimePicker;
if (editor != null)
{
editor.Culture = new System.Globalization.CultureInfo("en-US");
editor.Culture.DateTimeFormat.ShortDatePattern = "ddMMyy";
editor.Culture.DateTimeFormat.ShortTimePattern = "HHmm";
editor.Culture.DateTimeFormat.LongDatePattern = "dd.MM.yyyy";
editor.Culture.DateTimeFormat.LongTimePattern = "";
editor.DisplayFormat = DateTimePickerFormat.Long;
}
}
Please let me know if any of these approaches works for you.
Regards,
Dilyan Traykov
Progress Telerik

Hi Dilyan,
this is working perfekt!!!!!
Thanks a lot, BR
Gert

After a few days working in production with this new format behaviors some of the users (ofcause) are complaining that they are not able now to copy - paste dates (e.g. 21.02.2020) from one date column to the other.
Just out of curiosity, is it possible some how to switch the ShortDatePattern depenting on the input string or in other words when the user is entering a "." or the paste string contains any "." the ShortDatePattern switches to "dd.MM.yyyy" else it is "ddMMyy" ??
This would be the superlative solution for our system.
Thanks in advance,
Gert
Hi Gert,
In such case, I can suggest creating custom parsing logic for the control as explained in this article. Alternatively, you can handle the PastingCellClipboardContent event of the RadGridView control.
Please let me know if any of these approaches would work for you.
Regards,
Dilyan Traykov
Progress Telerik

Hi Dilyan,
the ParseDateTimeValue event meets exact all my needs. Thanks a lot!!!
In the future I have to spend more time in telerik documentation, I promise.
Have a nice day!!
BR Gert