Click here to Skip to main content
Licence 
First Posted 11 Nov 2003
Views 220,221
Downloads 2,856
Bookmarked 46 times

Nullable DateTimePicker

By Pham Minh Tri | 17 Nov 2003
A standard DateTimePicker control that enables users to enter null value. The fact that it's not intensively modified ensures that it has no potential errors.
1 vote, 3.1%
1
1 vote, 3.1%
2
1 vote, 3.1%
3
6 votes, 18.8%
4
23 votes, 71.9%
5
4.74/5 - 32 votes
2 removed
μ 4.57, σa 1.68 [?]

Sample Image - Nullable_DateTimePicker.jpg

Introduction

I had do a research on a DateTimePicker that could enter null value and found a lot of solutions to it. But one major problem with those is that they behave quite different from the standard ones and may have many potential bugs, as a result it took time to test before using in a real application. I just found another simple solution that could solve this problem with a little modification, so it could promise no bugs :-).

Solution

I have overridden the Value property to accept Null value as DateTime.MinValue, while maintaining the validation of MinValue and MaxValue of the standard control. That's all there's to it.

Because it's so simple, there's not much to say about it. Please refer to code for details.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Pham Minh Tri



Vietnam Vietnam

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionJust what I needed Pinmembergemini_dk5:43 20 Dec '11  
AnswerRe: Just what I needed Pinmemberjf645:57 25 Jan '12  
GeneralNo hour in sql database Pinmembercyrilcp1:16 9 Nov '10  
GeneralValidation wrong value fix PinmemberPREMSONBABY5:38 20 May '10  
GeneralRe: Validation wrong value fix Pinmemberoliwan13:16 30 Sep '10  
GeneralRe: Validation wrong value fix PinmemberDeuceDude16:46 28 Oct '11  
Generalthank you for your help! Pinmemberwuhai080915:52 5 May '10  
GeneralSet Nullable DateTimePicker default value [00/00/0000] Pinmembertinhleduc1:27 26 Feb '10  
GeneralUpdate PinmemberRomain TAILLANDIER23:37 21 Sep '09  
GeneralThis is a very insightful approach to the problem PinmemberPhil Raevsky17:01 28 Aug '09  
GeneralThis one dispaly pink if null date (VB.NET) PinmemberLarry Rouse12:32 28 Aug '09  
GeneralThis one works! (VB 2008) [modified] PinmemberJeromeyers13:55 10 Feb '09  
GeneralRe: This one works! (VB 2008) PinmemberEMYNA13:40 28 Oct '09  
GeneralUse the Nullable Datetime for a more updated solution. Pinmemberchstngs6:39 7 Oct '08  
GeneralIt's really great! Thank you very much!! Pinmemberwxpwu3:48 15 Jun '08  
GeneralSmall correction PinmemberMaxxx3332:32 16 Nov '06  
GeneralRe: Small correction - an enhancement to that correction Pinmemberccbt20:27 9 Sep '09  
GeneralRe: Small correction - an enhancement to that correction BugFixing =) [modified] PinmemberLeonunicorn2:45 4 Dec '09  
GeneralRe: Small correction - an enhancement to that correction BugFixing x 2 [modified] Pinmemberkipotlov7:14 11 Dec '09  
GeneralRe: Small correction - an enhancement to that correction BugFixing x 2 PinmemberLeonunicorn5:57 15 Dec '09  
GeneralRe: Small correction - an enhancement to that correction BugFixing x 2 PinmemberLeonunicorn4:42 4 Jan '10  
QuestionNull Button? PinmemberKysonel10:48 28 Mar '06  
I found this pretty usefull, but do you know a way to place a button in the calendar to place the null value? like the "today" button there is in the lower left corner... I'm using vb.net :P just so you know.
 
thanks!
QuestionHow to use? Pinmemberstrent006:54 21 Dec '05  
GeneralCool! PinmemberSuper Lloyd17:36 19 Dec '05  
GeneralClicking on current date in dropdown doesn't show datetime Pinmemberjfk80@wp.pl3:38 15 Mar '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120210.1 | Last Updated 18 Nov 2003
Article Copyright 2003 by Pham Minh Tri
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid