5,696,576 members and growing! (16,954 online)
Email Password   helpLost your password?
Desktop Development » Selection Controls » Date/Time controls     Intermediate

Nullable DateTimePicker

By Pham Minh Tri

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.
C#.NET 1.0, Win2K, WinXP, Win2003, Windows, .NET, Visual Studio, Dev

Posted: 11 Nov 2003
Updated: 17 Nov 2003
Views: 134,004
Bookmarked: 31 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
25 votes for this Article.
Popularity: 6.36 Rating: 4.55 out of 5
1 vote, 4.0%
1
1 vote, 4.0%
2
1 vote, 4.0%
3
4 votes, 16.0%
4
18 votes, 72.0%
5

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



Location: Vietnam Vietnam

Other popular Selection Controls articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 31 (Total in Forum: 31) (Refresh)FirstPrevNext
GeneralUse the Nullable Datetime for a more updated solution.memberchstngs6:39 7 Oct '08  
GeneralIt's really great! Thank you very much!!memberwxpwu3:48 15 Jun '08  
GeneralSmall correctionmemberMaxxx3332:32 16 Nov '06  
GeneralNull Button?memberKysonel10:48 28 Mar '06  
GeneralHow to use?memberstrent006:54 21 Dec '05  
GeneralCool!memberSuper Lloyd17:36 19 Dec '05  
GeneralClicking on current date in dropdown doesn't show datetimememberjfk80@wp.pl3:38 15 Mar '05  
Generalbind data to date time pickermemberccloon23:11 20 Feb '05  
GeneralRe: bind data to date time pickermemberClaudio Grazioli11:36 28 Mar '05  
GeneralRe: bind data to date time pickermemberClaudio Grazioli23:45 24 May '05  
AnswerRe: bind data to date time pickermemberalc_aardvark7:07 14 May '08  
GeneralDisplay blank space when NULLmemberSupaHoopsa5:56 9 Feb '05  
GeneralRe: Display blank space when NULLmemberClaudio Grazioli23:16 19 Apr '05  
GeneralThank youmemberjanine_olley5:37 12 Oct '04  
General"Error creating window handle error" on TabControl controlmemberSMiLEZ9:11 28 Sep '04  
GeneralRe: "Error creating window handle error" on TabControl controlmemberBrett Zimmerman17:00 5 Oct '04  
GeneralRe: "Error creating window handle error" on TabControl controlmemberClaudio Grazioli22:02 18 Apr '05  
GeneralThanksmemberTom Fischer5:30 18 Jun '04  
GeneralCould you have vb.net versionmemberTony Dong12:10 25 May '04  
GeneralNice control, but ...memberSachaMartineau4:38 25 Feb '04  
GeneralRe: Nice control, but ...memberChristian Graus13:40 25 May '04  
GeneralRe: Nice control, but ...memberSteveHolland3:48 2 Feb '05  
GeneralOverrides value??memberEntLover4:32 12 Jan '04  
GeneralRe: Overrides value??sussUDALO7:39 17 Feb '04  
GeneralAdd ShowUpDown property supportsussetranger18:11 2 Jan '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 17 Nov 2003
Editor: Smitha Vijayan
Copyright 2003 by Pham Minh Tri
Everything else Copyright © CodeProject, 1999-2008
Web20 | Advertise on the Code Project