Initialize the DateTimePicker control to a blank value by setting the Format property to Custom and the CustomFormat property to a space (" "):
DateTimePickerConstDate.CustomFormat = " "
DateTimePickerConstDate.Format = DateTimePickerFormat.Custom
Then, when the value changes, change the Format property back to its original value (or define a usable Custom Format:
Private Sub DateTimePickerConstDate_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DateTimePickerConstDate.ValueChanged
DateTimePickerConstDate.Format = DateTimePickerFormat.Short
End Sub
For more information on this solution and other approaches, see the following:
http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/46b2a370-72ec-485c-9361-bfa505bb6863/
17 comments:
Awesome
Tkx, tkx, tkx and si simple !
Thanks for the tip, it came in handy. I added a bit more to it (giving the user the ability to use delete/backspace to null out the value after setting an initial value)
http://nodedangles.wordpress.com/2010/07/13/datetimepicker-null-value/
Somehow the calenderbox doesnt close when i pick the first date. Any solutions?
Srego, you are the best.
Thanks really it worked like a charm.
This has made my day
Thanks
Thanks, It is a simple solution to a complex problem.
Please share your knowledge with others like this.
God bless you.
The screen looks blank, exactly what I was trying to achieve, however the datetimepicker still has a value. I want to check if the value has been set, but it always returns the current date/time. I have tried setting the value to the minimum date value, then doing a check to see if it's the min date, then show blank. This works, but when the user goes to enter a 'proper' date, the picker starts off with a date in 1753 so the user has to scroll through 250 years before getting to a reasonable date.
So, in short, how do you set the value of the datetimepicker to blank?
thanks..it works for me..appreciate you.
ok if you want to take default value as null to table you check its format. for blank custom format it is 8 and short it is 2.
Very helpful, thanks a lot
This is so awesome. Many thanks.
This is so awesome, it helped me a great deal. Many thanks.
good one
This works great. The only issue I see is that after the date value is used and is blanked out you cannot select the exact same date again. Did anyone else have this issue and resolve it? If you did, can you post your solution. - Thanks in advance
Thats Awesome !!! That solution worked perfectly.
Many many...Thanks
Perfect!
Post a Comment