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
70
Changing Time on UltraCalendarCombo without typing colon
posted

I have an UltraCalendarCombo where I have set the format to:  MM/dd/yy   HH:mm

when a user highlights the time portion and types a new 4 digit time, the new value is not retained when the user tabs away from the control.

if the user types in the colon in between the 4 digits, then the value IS retained.  Is there a way to retain the value when the colon is not typed?

  • 7695
    Verified Answer
    Offline posted

    Hi Jesus,

        There are a few ways to handle this, one would be to use an UltraMaskedEditor. But try this, handle the ValidationError event and do an additional parse attempt on the date with something like:
    private void CalCombo_ValidationError(object sender, DateValidationErrorEventArgs e)
    {
     if (e.ErrorCode == DateValidationError.UnableToParseValue)
     {
      DateTime dtNew = DateTime.MinValue;
      if (DateTime.TryParseExact(e.ErrorValue as string, "MM/dd/yy HHmm", System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out dtNew))
      {
       e.NewValue = dtNew;
      }
     }
    }

    Let me know how this works for you,