Bob
asked on
How is the DateTimePicker "Cleared."
Been searching for the answer with no success. All I've read is how DateTime is not nullable. No explanation. It's probably due to it being a data structure, I guess.
What's needed is clearing the DTPs before a new doc is created. Since it's not nullable, how do you guys "clear" the DTP in VB.NET 2017?
Thanks for any help.
--Bob
What's needed is clearing the DTPs before a new doc is created. Since it's not nullable, how do you guys "clear" the DTP in VB.NET 2017?
Thanks for any help.
--Bob
Hi Bob,
https://docs.microsoft.com /en-us/dot net/visual -basic/pro gramming-g uide/langu age-featur es/data-ty pes/nullab le-value-t ypes
DateTime is nullable.
Now clearing a DatePicker, are you making a Desktop App or a WebApp?
Regards,
Chinmay.
https://docs.microsoft.com
DateTime is nullable.
Now clearing a DatePicker, are you making a Desktop App or a WebApp?
Regards,
Chinmay.
you can handle it by using an empty CustomFormat as shown in https://www.emoreau.com/Entries/Articles/2005/01/The-DateTimePicker-control.aspx
ASKER
That's an error in your code, not the date picker. Go to that function in your code--you're trying to access the value of a nullable object, but that object is null.
e.g.
e.g.
DateTime? x = null;
DateTime y = x.Value; // InvalidOperationException
ASKER
ASKER
kaufmed, I understand your post. Thank you.
What's needed is to clear a DateTimePicker control. Any ideas on how to do this?
--Bob
What's needed is to clear a DateTimePicker control. Any ideas on how to do this?
--Bob
I thought it was WinForms! Have a look at https://stackoverflow.com/questions/23121933/problems-setting-wpf-datepicker-to-null
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
A different option would be to set the DateTimePicker to a default value (Today?).