Datetimepicker Control

frankdaniels

Member
Joined
Jan 27, 2006
Messages
10
Programming Experience
Beginner
Need Assistance! I am completely stumped. I have read all the threads related to DTP's, and tried everything I can think of. I KNOW the solution is simple, but it is eluding me. Can Anyone please put me out of my misery? Here it is - I have a DTP on a form. When the form loads, how do I set the value, and the text to a predefined "default"? What happens when the form loads, the DTP control inserts the current date. HELP ME PLEASE !!!
 
Thanks for our expedient reply. It does not work however. When the form loads, the date shown in the DTP is still the current system date.
 
Well, it depends on WHEN you run that code....
Look in the form constructor, there's a call to a sub called InitializeComponent() -- it'll be in the region labeled "Windows Form Designer generated code" .... right after that is a comment "Add any initialization after the InitializeComponent() call" ... it's right after this that you will want to put that code to set the DTP.

That should do it.

-tg
 
If you do not set the Value in the designer then the default behaviour is to use the current date and time. If you know what this desired date is at design time then you should be setting it in the designer. Go to the Properties window and set the Value property. If the value is not known until run time, like it comes from a database or from the user or something, then either the end of the constructor, as suggested, or the form's Load event handler are the appropriate places to set it.
 
I think I have it - in the forms load event, I had a sub which "cleared all controls" haha. So it basically removed the value that I had defined. Doh. Thanks for all your help guy. No doubt I will need your assistance in the near future....... thanks.
 
Back
Top