469,611 Members | 1,718 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,611 developers. It's quick & easy.

How to get a DateTimePicker accept and show empty date (emty string/space/null)?

My customer needs a DateTimePicker in VS2005 C# that can show emty date
values (blank/space/null).

I need a control that:

1. Can show a blank value
2. Detete a date when hitting the delete and/or back key
3. Allowse the user to enter yyyy-MM-dd date format manually
4. When tabbed into the field behaves juast like a textbox

and of course dropdown the datepict -calender...
I cannot getthe standard control to do this so I searched on the net.
I have tried several of the solutions that I found bun none worked OK.
The best (TAS DateTimePicker:
http://www.codeproject.com/cs/miscct...&forumid=14186)
works exactly like I want, but it is not VS2005. So I migrate it and get no
errors, build it with errors but when I drag it to the form I get an errror
that the string is not in correct date format...

Anybody have a solution of any kind???

TIA

Claes
Mar 28 '07 #1
2 7950
On Mar 28, 1:20 pm, "Claes Wedin" <claes.we...@altcom.sewrote:
My customer needs a DateTimePicker in VS2005 C# that can show emty date
values (blank/space/null).

I need a control that:

1. Can show a blank value
2. Detete a date when hitting the delete and/or back key
3. Allowse the user to enter yyyy-MM-dd date format manually
4. When tabbed into the field behaves juast like a textbox

and of course dropdown the datepict -calender...
I cannot getthe standard control to do this so I searched on the net.
I have tried several of the solutions that I found bun none worked OK.
The best (TAS DateTimePicker:http://www.codeproject.com/cs/miscct...epicker.asp?df...)
works exactly like I want, but it is not VS2005. So I migrate it and get no
errors, build it with errors but when I drag it to the form I get an errror
that the string is not in correct date format...

Anybody have a solution of any kind???

TIA

Claes
You can make the DateTimePicker show a blank on the control using this
code:

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "''";

Notice that the Custom format is a string of 2 apostrophes.

Note also that this does not change the date VALUE of the
DateTimePicker, only the display.

Chris

Mar 29 '07 #2
Thanks, a good idea but it does not help because we need to:

1. Make the value nullable...
2. Allow the user to enter the date manually (or use the calender)

but I think I know how to do this:

Place a textbox in front of the datetimepicker, hiding the datefield but not
the drop-arrow If the user uses the calendar just place the date in the
textbox and if the user enters it manually, just validateit...
Apr 3 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Angelina | last post: by
4 posts views Thread by Jacek Jurkowski | last post: by
7 posts views Thread by Clamara | last post: by
11 posts views Thread by jessy | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.