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
60
UltraDateTimeEditor - ValueChanged event fires too early
posted

When keying a date into an UltraDateTimeEditor, the ValueChanged event fires when 5 digits are entered .. for example  1  2  3  1 0 will fire ValueChanged, and the value is Dec 31, 2000.  This makes subscribing to the ValueChanged event handler unusable.  Typically, my users would enter 2 to 4 digit years, never a 1 digit year.

However, when a user chooses a date from the calendar drop down, I want to immediately respond to this choice.  I can only do this by subscribing to the ValueChanged event, but that is unreliable.  Instead, I must use either Leave or AfterExitEditMode, which isn't as slick and responsive as I want my application to be.

So I really have two issues:

  • How to suppress ValueChanged when only 1 digit was entered for the year
  • How to capture that the user picked a date from the drop calendar

An answer to either of these would give me something to work with.  Thanks!

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi Greg,

    The reason it works this way is that the control is using DateTime.Parse to make a date out of the text you entered.

    When you enter a "1", DateTime.Parse will failed to convert this into a valid date. So the value of the control will be null. When you type the "2", once again, this will fail to make a valid date, and so the value of the control is still null. Since there has been no change, the ValueChanged doesn't fire.

    Once you get to "12310", this is the first time that DateTime.Parse resolves to a valid date and so the Value of the control changes at this point.

    So the only way I can see for you to get around this would be to examine the Text property inside ValueChanged and see how many digits there are or do your own date parsing to determine if you want to respond or not.

Reply Children
No Data