Home Forums WinForms controls Other WinForms controls WinDatePicker Validation

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18271 |

    How can I turn validation off? This is the scenario I’m looking for:

    Form opens — WinDatePicker shows default value.
    User does a “select all” and hits delete.
    WinDatePicker now shows “__/__/____”.
    User enters “02” for the month.
    WinDatePicker now shows “02/__/____”.
    User decides to tab to a different control for a moment.
    This causes WinDatePicker to lose focus, but it still shows “02/__/____”.
    User tabs back to the WinDatePicker control and finishes filling in the date.

    How can I allow this? Currently, the control won’t allow the focus to change to another control unless a valid date is entered, OR if it’s cleared out completely (“__/__/____”). I want to validate the control’s value at a later time.

    Imported from legacy forums. Posted by Glenn (had 3316 views)

    User (Old forums)
    Member
    Post count: 23064

    I figured part of it out. If I override the OnValidating() method of the WinDatePicker and always set e.Cancel = false, the user can tab away from the control at any time. Now the problem is that the control’s text doesn’t stay the same when the user tabs away from the control. Example:

    Form opens — WinDatePicker shows default value.
    User does a “select all” and hits delete.
    WinDatePicker now shows “__/__/____”.
    User enters “02” for the month and “03” for the day.
    WinDatePicker now shows “02/03/____”.
    User decides to tab to a different control for a moment.
    WinDatePicker now shows “0203” (instead of “02/03/____”).

    Any ideas?

    Imported from legacy forums. Posted by Glenn (had 288 views)

    User (Old forums)
    Member
    Post count: 23064

    Unfortunately, it will not be possible to do more than this.

    Imported from legacy forums. Posted by André (had 271 views)

    User (Old forums)
    Member
    Post count: 23064

    Andre,

    Thanks for the reply. I was able to do what I wanted without using WinDatePicker, but using WinTextBox with a mask.

    -GL

    Imported from legacy forums. Posted by Glenn (had 4307 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.