Datetimepicker validating event

07-Feb-2020 11:01 by 3 Comments

Datetimepicker validating event - dating services chat rooms

The following code example uses the derived class Text Box and validates an e-mail address that the user enters.If the e-mail address is not in the standard format (containing "@" and "."), the validation fails, an Error Provider icon is displayed, and the event is canceled.

The date time picker contains a validation event which may be handled in code; the problem with validating the control using its validation event is that, if the validation includes confirmation of the change, the validation event will fire twice.

The next bit of code to look at in this form is the date time picker's Close Up event handler; it is in this handler and not in the control's validation event handler that we actually do the validation; by making the check here we may perform the validation and possibly the rollback to the prior value without issuing the duplicated confirmation message.

In this code, the confirmation box is display; if the user selects "Yes", the previous time value is set to contain the value contained in the date time picker; if the user selects "No", the date time picker value is returned to previous value using the copy contained in the previous time variable.

Doing so can cause your application or the operating system to stop responding.

For more information, see the WM_KILLFOCUS topic in the "Keyboard Input Reference" section, and the "Message Deadlocks" section of the "About Messages and Message Queues" topic in the MSDN library at

control is just a wrapper around the native common Date Time Picker control, you can create a derived control to allow your application to parse the input string. Style Or DTS_APPCANPARSE Return cp End Get End Property #Region "Native Structures" Structure NMDATETIMESTRING Public nmhdr As NMHDR Public psz User String As Int Ptr Public st As SYSTEMTIME Public dw Flags As GDT End Structure Public Enum GDT GDT_ERROR = -1 GDT_VALID = 0 GDT_NONE = 1 End Enum _ Public Structure SYSTEMTIME Public w Year As Short Public w Month As Short Public w Day Of Week As Short Public w Day As Short Public w Hour As Short Public w Minute As Short Public w Second As Short Public w Milliseconds As Short End Structure _ Public Class NMHDR Public hwnd From As Int Ptr = Int Ptr.

Is here any trick to turn off this internal validation of dtp or any other way to get wanted (described) functionality in given circumstances?

Value Then Msg Box("Date Error") Date Time Picker1. Thats very odd.....using your code on my PC (VS 05) it pops up the error once but does not loop, even if I pick a year in the future.

I can make a Date Time Picker so that it shows a checkbox to enable / disable the date.

I tried to find the event that is fire when the user changes this value, but I was unable to find it.

Is there no such event, or did I look in the wrong place?

If the developer opts to perform the confirmation task in the date time picker's value changed event handler, the user will presented with two confirmation boxes each time the value is changed and then restored to its previous value.