![]() |
Languages »
VB.NET »
General
Intermediate
Date Control Better then DateTimePickerBy Muhammad Abubakar DarAssumed to makes possible input of date values as fast as user can via keyboard also has ability to pick date from picker like tradition DateTimePicker |
VB.NET 1.1, Win2K, WinXPVS.NET2003, Architect, DBA, Dev, QA
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

In a database application Date data type handling is a bit difficult as compared to other data types and getting input by keyboard is required some extra efforts. Common solution to this problem is the DateTimePicker control provided by Microsoft. Unfortunately DateTimePicker is not best suited for fast data entry via keyboard that is always required in a database driven applications. I have got several complains from end users that he don�t want to use mouse for date selection or when entering date in DateTimePicker via keyboard require extra keys has to be pressed from moving cursor from one day part to next and so on. This is the motivation behind the development of a new DateTimePicker, which will enable users to enter data fast and in alternate ways either by keyboard or by using mouse.
What I have done is, created a textbox masked control to input date via keyboard and also attached a DateTimePicker control to input date via mouse .It also has the functionality to validate user input if the date is not valid than the text color is displayed in red. Also set its property �IsValid� to false. To validate date what I have done is a trick just set the value of DateTimePicker with value entered in TextBox , DateTimePicker will generate an exception for invalid date value and the color will change to red.
It is quite easy to use like other controls just add to your toolbox drop on the form you want to use. I am giving you people here the over view of properties that can be used while in design time and run time
I have tried to expose properties just like DateTimePicker so that if you are going to replace DateTimePicker from your existing project with this one you don�t have to change your code.
Custom Properties, events, methods, their description and reason why I have created
the specific is as follows:
Value
Returns the value in the form of date; same as of DateTimePicker
Day
Is same as in DateTimePicker�s �Value.Day� statement, but u will get one step in advance, simply �Control1.Day�.
Month
Is same as in DateTimePicker�s �Value.Month� statement, but u will get one step in advance, simply �Control1.Month�.
Year
Is same as in DateTimePicker�s �Value.Year� statement, but u will get one step in advance, simply �Control1.Year�.
SQL Value
The specific property required when using the value of DateTimePicker with SQLServer, Because SQL Server requires a date format of �yyyy\MM\dd� to work fine .This property returns the Formated Date.
DateFormat
Specify Date Format you want to use, currently there are three supported formats DMY,MDY,YDM
IsValid
A ReadOnly property that return the state of the control. This property can be used for validating form input before submitting back to DBMS.
AllowNull
This property is being used to replace the checkbox that is displayed with default DateTimePicker, that often create problem whenever you try to check or uncheck it in code. So for now, when we need to have Null-able date column, this property will be used either to Allow null or not, it will return null if textbox is empty means user doesn�t want to enter the date.
ValueChanged
You can write your custom code for the value changed event as we write for DateTimePicker.
Clear
It can be used to clear the date if AllowNull is set to true then it will set value property to Null and clear the text of the control otherwise set the control text to current date and value accordingly.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 29 Mar 2006 Editor: |
Copyright 2006 by Muhammad Abubakar Dar Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |