Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
How to keep the time when changing date in UltraCalendarCombo?
posted

When I change the date by clicking in the MonthCalendar, it takes the time to 12:00 (time 0, as it is assigning a brand new datetime). I want to update only the date part of the DateTime, and keep the same time I use to have.

Why not using UltraDateTimeEditor then?

Because it is very uncomfortable to edit, you have to type the entire Date and Time to be valid and it doesn’t Apply when pressing Enter key.

 

Parents
No Data
Reply
  • 69832
    Offline posted

    You have to incorporate the time into the DateTime value that you assign to the control's Value property:

    DateTime dateToSet = new DateTime(2008, 1, 1);

    if ( this.ultraCalendarCombo1.Value is DateTime )
    {
        DateTime currentValue = (DateTime)this.ultraCalendarCombo1.Value;
        DateTime newValue = dateToSet.Date;
        newValue = newValue.Add( currentValue.TimeOfDay );
        this.ultraCalendarCombo1.Value = newValue;
    }
    else
        this.ultraCalendarCombo1.Value = dateToSet;

     

Children
No Data