date time picker null value

Hi

I am having trouble using the DateTimePicker control.  

I basically want to print out each time a user choses a date.  So I use the ValueChanged event.  

However everytime I run my program, the DateTimePicker starts with a null value.  I found this out by just having a messagebox display the dateTimePickerControl.value.

I have the Control on a panel that is not initially visible, so only when I change to that panel is where the right date gets displayed.

Since it is a null value any other methods that I run because of a date change crash my program.  

I was thinking of creating the control dynamically, but I was wondering if there was another way?
LVL 7
foobarrAsked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
Hi foobarr,

See my article of January 2005 at http://emoreau.s2i.com/

Cheers!
0
 
foobarrAuthor Commented:
Well I change the messagebox to print out the Value of the control and it worked fine...but it only displays the date and time a generic way

I need it formatted to yyyy-MM-dd cuz i'm using mysql so I need to use the control.text which gives me a null value when loading hte program up
0
 
heintalusConnect With a Mentor Commented:
Just use the ToSting function & pass it the format you want
i.e.
dateTimePickerControl.Value.ToString("yyyy-MM-dd")
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.