You can try something like this:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.DateTimePicker1.Format = DateTimePickerFormat.Custom
Me.DateTimePicker1.CustomFormat = " "
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.DateTimePicker1.Format = DateTimePickerFormat.Custom
Me.DateTimePicker1.CustomFormat = " "
End Sub
Private Sub DateTimePicker1_DropDown(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DateTimePicker1.DropDown
Me.DateTimePicker1.CustomFormat = "yyyy/MM/dd"
End Sub
Private Sub DateTimePicker1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles DateTimePicker1.KeyDown
If e.KeyCode = Keys.Delete Then
Me.DateTimePicker1.CustomFormat = " "
ElseIf Me.DateTimePicker1.CustomFormat = " " AndAlso _
(e.KeyValue >= 48 AndAlso e.KeyValue <= 57) OrElse _
(e.KeyValue >= 96 AndAlso e.KeyValue <= 105) _
Then
Me.DateTimePicker1.CustomFormat = "yyyy/MM/dd"
End If
End Sub
--
HTH
Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(
www.s2i.com)
"XmlAdoNewbie" <er************@cowaninsurancegroup.com> wrote in message
news:c9**************************@posting.google.c om...
Hi All,
I am wondering if it is possible to allow nulls or empty strings when
it comes to the datetimepicker control. I have an app with a few
datetimepickers on it and there are some instances when i don't want a
date to show at all but the datetimepickers always have at least
todays date in it so when i go to press the save button on my app
there is always a date stored in the retrieved field. Is there a way
to say "hey i don't want a date stored in this field, i want "" or
null"
thanks
Erin