473,614 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DateTimePicker Control

I am trying to write an app in C# that requires the user to enter a date
from 4000 B.C.E to 4000 C.E. I tried to use the DateTimePicker Control
to allow the user to enter the date, but it only supports the Gregorian
Calendar, so the earliest date it allows is in 1752 C.E.

Is there a way to override the DateTimePicker control's minimum allowed
date, or am I forced to resort to the less user-friendly use of three
separate text boxes for month, day and year?

Todd

Jun 30 '08 #1
2 5215
You can extend the DateTimePicker control, there is a sample in:
http://www.codeproject.com/KB/select...imepicker.aspx

Before extending you need to be aware of the following facts:
DateTimePicker has a date range: 1 Jan 1753 - 31 Dec 9998
System.DateTime type has date range: 1 Jan 0001 - 31 Dec 9999
SQL Server DateTime type has date range: 1 Jan 1753 - 31 Dec 9999

--
dUKE
"Todd Carnes" wrote:
I am trying to write an app in C# that requires the user to enter a date
from 4000 B.C.E to 4000 C.E. I tried to use the DateTimePicker Control
to allow the user to enter the date, but it only supports the Gregorian
Calendar, so the earliest date it allows is in 1752 C.E.

Is there a way to override the DateTimePicker control's minimum allowed
date, or am I forced to resort to the less user-friendly use of three
separate text boxes for month, day and year?

Todd

Jul 1 '08 #2
dUKE wrote:
You can extend the DateTimePicker control, there is a sample in:
http://www.codeproject.com/KB/select...imepicker.aspx

Before extending you need to be aware of the following facts:
DateTimePicker has a date range: 1 Jan 1753 - 31 Dec 9998
System.DateTime type has date range: 1 Jan 0001 - 31 Dec 9999
SQL Server DateTime type has date range: 1 Jan 1753 - 31 Dec 9999
Thank you very much for the link. I do have one more question.

If I extend the DateTimePicker to accept the dates I require, I
shouldn't need to worry about the limitations you listed above as long
as I'm handling all the actual processing of the dates with my own code,
correct? ... Or will the System.DateTime limitation still be a problem?
(SQL Server's not going to be in the picture for this project.)

Todd
Jul 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3956
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it will not set the value of the control and will leave the checked status of the checkbox to false when a user selects a new date. this works fine when using the control on a win2k machine but if we use it on a win XP box and call
4
5678
by: Jacek Jurkowski | last post by:
.... the minimum date of DateTimePicker is 1753-01-01. How to make DateTime to do not show nothing in its text if this date is the value? I have a form with a field LastLogonDate. If user hasn't logon yet this date should be empty but when binding a property to the DateTimePicker value it always shows value parsed prom property which is 1753-01-01. How to make an "empty" or "not set" date bindable to a value property of DateTimePicker?
7
6199
by: Clamara | last post by:
When adding a new record from my form, I pre-set my DateTimePicker's value to System.DateTime.Today Since the "Today" value is used most of the time, the user doesn't need to select a date from the DateTimePicker, since the default is shown. My problem is, if the user does not choose a value from the DateTimePicker (because using the default is good enough), then during database update, the date value is not saved to the database; while if...
3
6369
by: Charlie | last post by:
In the top portion of the DateTimePicker, where the value of the date is displayed, how can I detect whether the month or day or year is currently focused, or, if ShowCheckBox = True, whether the checkbox is focused?
0
3546
by: thull | last post by:
I'm trying to modify an older VB6 program and use the DateTimePicker control to give the user the ability to display and modify the system date and time. The VB6 documentation says it is available (e.g. not a newer .NET control), and is part of the Active-X (.ocx) called MSCOMCT2.OCX (in the \winnt\system32 directory), which I can see that it is there. When I go to add the control to my project (e.g. Projects -> Components) and scroll down...
3
7502
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going on. It's a simple program that loads a control onto a form and binds "Foo" against a combobox ("SelectedItem") for it's "Bar" property and a datetimepicker ("Value") for it's "DateTime" property. The DateTimePicker.Visible value is set to...
1
1923
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I posted this about a month ago but didn't get any response, so I thought I'd rephrase it. I have a DateTimePicker set for Up/Down Time format (HH:mm:ss). The problem is that when I click past 59 seconds the minutes do not increment, and similarly for minutes affecting hours. Also, similarly for clicking backwards from 00. I've seen this work in other applications so it must be simple. I could use a value changed event and...
4
3293
by: jehugaleahsa | last post by:
Hello: We were hoping to allow users to have DateTimePicker value null so that a unused date is stored on a Database. Does the control support this? I am pretty sure it doesn't. How would you go about representing this to a user so they are not confused? Thanks,
0
5644
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be blank unless they are filled by the user. 2) As soon as the user enters a cell, the dtp control should appear as the editing control of that cell. If there's a value in the cell beforehand, that value is set as the value of the dtp editing control...
0
8198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8642
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8591
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8294
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8444
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.