Question Best way to do datetime text box?

wouterv81

Member
Joined
May 3, 2012
Messages
7
Programming Experience
1-3
Hi,

I know there's lots of postings on this topic, but none that I found could help me out.

I'm trying to have a text box (let's call it textbox1.text) which the user can either leave blank, or where the user can populate a date,
which should show in the dd-mmm-yyyy format after entry (entry either through datetimepicker or masks or other)

This textbox will be linked to a record in an access table.

For now I've managed to use a simple text box, and managed to handle the null/blank issues with the data going to and from Access. But I'd like to make sure the user does not enter rubbish.

Any suggested methods are welcome.

Thanks!
Wouter
 
Herman,

I've tried the DateTimePicker object but it looks like I cannot display a blank value with it.
Upon creation of a new record, I try to blank out these fields, and it always shows the date of today.

How can I allow blanks with the DateTimePicker?

Thanks
Wouter
 
I'm not binding any data to the control.

The only thing I did was drag a new DateTimePicker control onto my form, change the Format to Custom, and add to customformat "dd-MMM-yyyy".
I then have some code upon opening the form to pull data from an access table onto the form, and to write back from the form to Access.
In Access, some of the records have dates in it, some are blank
 
If you're not binding then you can use a standard DateTimePicker. Set ShowCheckBox to True and then Checked property indicates whether you should honour the Value property or not. If you want, you can change the CustomFormat to a single space and then the control will be blank when unchecked instead of greyed out. There's a custom control here that does that for you and it also supports binding to nullable data, which the standard control does not:

Quantum Software Solutions - Windows Forms Components
 
Last edited:
Back
Top