I am using the RadDateTimePicker and the RadTimePicker (WinForms Version 2012.2.608.20) to set the Date and Time of a meeting (they are bound to the same column of a datatable).
I'm finding that when I change the date, the time is always being reset to midnight.
Is there a way to get the RadDateTimePicker to only change the date, leaving the time alone ?
7 Answers, 1 is accepted
Thank you for contacting the Telerik support.
RadDateTimePicker always resets the time when user select the new date from the calendar.
You can avoid this behavior by handling the PopupOpened and PopupClose events:
Please refer to the sample project.
All the best,
the Telerik team
Hi Telerik Team,
I am using the Telerik version of(2014.2.617.20) and I do have the same issue. In my form I have more than 10 raddatetimepickers
for each control I have repeat the same code or is there any optimized way to do this.
Any help would be appreciated.
Thank you for writing.
You can create a derivative of RadDateTimePicker implementing the custom behavior in it. Then, use the custom control where it necessary:
I hope this information helps. Should you have further questions I would be glad to help.
Telerik by Progress
Has anyone tried a VB version of this?
Converting the C# code from Peter (10 Oct 2012), I get this for the code in the example - which gives the error " 'Public Event Opened As EventHandler' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event." on the two Load event lines calendarBehavior.PopupControl....:
Private timeTest As DateTime
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim element As RadDateTimePickerElement = RadDateTimePicker1.DateTimePickerElement
Dim calendarBehavior As RadDateTimePickerCalendar = TryCast(element.GetCurrentBehavior(), RadDateTimePickerCalendar)
calendarBehavior.PopupControl.Opened = New EventHandler(PopupControl_Opened)
calendarBehavior.PopupControl.Closed = New RadPopupClosedEventHandler(PopupControl_Closed)
Private Sub PopupControl_Closed(ByVal sender As Object, ByVal args As RadPopupClosedEventArgs)
Dim dateStart As DateTime = RadDateTimePicker1.Value.Date
RadDateTimePicker1.Value = New DateTime(dateStart.Year, dateStart.Month, dateStart.Day, timeTest.Hour, timeTest.Minute, timeTest.Second)
Private Sub PopupControl_Opened(ByVal sender As Object, ByVal e As EventArgs)
Me.timeTest = Me.RadDateTimePicker1.Value
Please refer to the following code snippet demonstrating how to convert the mentioned C# code to VB.NET:
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Dess | Tech Support Engineer, Sr.
Hello Dess. Thanks for the AddHandler fix. Perfect.
I've also completed the modified RadDateTimePicker if anyone needs it: