Resolved displaying date as unanswered value

kpgraci

Active member
Joined
Feb 21, 2011
Messages
30
Location
New Orleans
Programming Experience
10+
I have a datepicker control that displays an appointment date. This date may be nothing, but the datepicker always displays a date, understandable I suppose.

There a plenty of occasions when I want a date to be null, and to display that status, how is this commonly handled in the user interface? I don't want to give up the nice functionality of the datapicker, but I need to somehow indicate that no date has yet been set.
 
Last edited:
I've got a fix for this, but its what I consider ugly. It looks fine from the users standpoint. Maybe I'm showing my ignorance, but it seem to me if the control developers introduced a DateNull value the lives of many programmers would be simplified. I'm sure there are technical reasons they do not, this just seems like a reoccurring hassle.

I went with the floating label over the datapicker solution. I used a label because I don't want the user directly editing the data, I want them to use the datapicker's dropdown calendar instead. So I size the label to overlay the datapicker text portion. To make this look right I had to override the paint event of the label to colorize the border to match the other controls on the form. Then to prevent Date.MinValue from being written to the database I had to modify my class save method to test for Date.MinValue (Well, actually #12:00 AM#) and write a DBNull.Vaue insted.

All in all it works and looks pretty good. The only problem, and it's not really a problem for this project, is that once a date is set is cannot be removed (since I'm using a label, the use can't erase it). If ever needed I could add a 'remove date' button, or use a textbox instead of a label.

I'll mark this as resolved but if anyone has a better idea I'd be interested.

I'm sure one other solution would be to create a custom control based on the datapicker, if I need to do this too often I'll consider that.
 
Back
Top