Extending a DateTimePicker Control

107 views
Skip to first unread message

EmJay

unread,
Sep 4, 2008, 7:02:15 AM9/4/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi all,

I have a need to be able to override the standard .NET 2.0
DateTimePicker control. Principally, I need to be able to adjust the
MinDate property to allow the control to go back to dates prior to the
adoption of the Gregorian calendar by Great Britain in 1752.

Initially, I'd like to be able to go back to 1582, when Pope Gregory
decreed that the new calendar should come into force.

At the same time, I'd like to be able to return years in a double-
dated fashion for those years between 1582 and 1752. This, to take
account of the traditional year in Great Britain running from March
25th to March 24th.

Subsequently, I'd like to be able to go back beyond 1582, into the
days when the Julian Calendar was still in widespread use.

Am I being a bit foolish in using the DateTimePicker as the starting
point? Or should I consider developing a class and control from
scratch?

Any advice and/or help much appreciated.

Regards
Mike Fry

Joseph Irizarry

unread,
Sep 5, 2008, 10:57:10 AM9/5/08
to DotNetDe...@googlegroups.com
It seems that there is no way to force the DateTimePicker to go before 1753. The absolute minimum date it will allow is stored in a readonly static variable. I have not other suggestions than to write your own calendar control (if you must stay  in the WinForms API).

If you want to try WPF (keeps you on the desktop): There is no DateTimePicker in WPF. But you can make your own, someone already has too. There is a pretty bit set of cool custom controls available at http://j832.com/bagotricks/.
Included in this download is the source code. There are two different types of date picker controls. The guy who did them has limited his min date to 1753 as well, but since you have the source code you can change that.

Another options is to use Asp.Net (you will have to build a web application): There is a Calendar control in that you can simply drag and drop on a page. It supports a lot of customization for looks, but most importantly it will go back far before 1753. I didn't run any tests to see just how far back, the furthest I have tested is Jan 1, 1400.

Hope this helps.

Mike Fry

unread,
Sep 5, 2008, 12:11:57 PM9/5/08
to DotNetDe...@googlegroups.com
Joseph Irizarry wrote:
> It seems that there is no way to force the DateTimePicker to go before
> 1753. The absolute minimum date it will allow is stored in a readonly
> static variable. I have not other suggestions than to write your own
> calendar control (if you must stay in the WinForms API).

Thought that might be the case

> If you want to try WPF (keeps you on the desktop): There is no
> DateTimePicker in WPF. But you can make your own, someone already has
> too. There is a pretty bit set of cool custom controls available

> at http://j832.com/bagotricks/. <http://j832.com/bagotricks/>


> Included in this download is the source code. There are two different
> types of date picker controls. The guy who did them has limited his min
> date to 1753 as well, but since you have the source code you can change
> that.

I'll have a look.

> Another options is to use Asp.Net (you will have to build a web
> application): There is a Calendar control in that you can simply drag
> and drop on a page. It supports a lot of customization for looks, but
> most importantly it will go back far before 1753. I didn't run any tests
> to see just how far back, the furthest I have tested is Jan 1, 1400.

No. Not building a web application. This is for a genealogical
transcription program that runs on the desktop.

Thanks for all the information. Guess I'll just have to have a go at
building my own control from scratch. Oh well. That'll add a week or so
to the project!

--
Regards,
Mike Fry
Johannesburg.

CK

unread,
Sep 8, 2008, 3:45:51 AM9/8/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
How about TextBoxes that only allow numeric entry. Would be far
easier for someone than clicking back a month/year a thousand times.

On 5 Sep, 17:11, Mike Fry <mike...@iafrica.com> wrote:
> Joseph Irizarry wrote:
> > It seems that there is no way to force the DateTimePicker to go before
> > 1753. The absolute minimum date it will allow is stored in a readonly
> > static variable. I have not other suggestions than to write your own
> > calendar control (if you must stay  in the WinForms API).
>
> Thought that might be the case
>
> > If you want to try WPF (keeps you on the desktop): There is no
> > DateTimePicker in WPF. But you can make your own, someone already has
> > too. There is a pretty bit set of cool custom controls available
> > athttp://j832.com/bagotricks/. <http://j832.com/bagotricks/>

Mike Fry

unread,
Sep 8, 2008, 5:26:16 AM9/8/08
to DotNetDe...@googlegroups.com
CK wrote:
> How about TextBoxes that only allow numeric entry. Would be far
> easier for someone than clicking back a month/year a thousand times.

True! NumericUpDown boxes would also suffice as well, except that I need
to allow for non-numerics in cases where elements of a date can not be
clearly read for transcription, and years prior to 1753 need to be
expressed as [Old Style]/[New Style] for the months January to March
e.g. 13 Mar 1750/51

Oh Well... begin the grind :-)

Joseph Irizarry

unread,
Sep 8, 2008, 11:16:57 AM9/8/08
to DotNetDe...@googlegroups.com
Haha, good point
Reply all
Reply to author
Forward
0 new messages