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

C

Claes Wedin

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/miscctrl/extended_datetimepicker.asp?df=100&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
 
C

Chris Dunaway

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/miscctrl/extended_datetimepicker.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
 
C

Claes Wedin

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top