473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Date Time Picker Question

Hi All,
I am wondering if it is possible to allow nulls or empty strings when
it comes to the datetimepicker control. I have an app with a few
datetimepickers on it and there are some instances when i don't want a
date to show at all but the datetimepickers always have at least
todays date in it so when i go to press the save button on my app
there is always a date stored in the retrieved field. Is there a way
to say "hey i don't want a date stored in this field, i want "" or
null"
thanks
Erin
Nov 16 '05 #1
7 10723
Hi Erin,
Hi All,
I am wondering if it is possible to allow nulls or empty strings when
it comes to the datetimepicker control. I have an app with a few
datetimepickers on it and there are some instances when i don't want a
date to show at all but the datetimepickers always have at least
todays date in it so when i go to press the save button on my app
there is always a date stored in the retrieved field. Is there a way
to say "hey i don't want a date stored in this field, i want "" or
null"
thanks
Erin


Some time ago i want to make a null visible in DateTimePicker but i
found it is impossible.

Only thing You can do is:
1) Using tricks to set null value e.g. by handling KeyDown event "Delete"

or

2) Writing Your own control based on TextBox or use two controls.
- Replace TextBox with DateTimePicker on Enter
- Hide DateTimePicker on Leave and store (or remove) value.

If You'll find any easier way the let me know at:
mgrzebski(at)taxussi.com.pl

Regards

Marcin
Nov 16 '05 #2
You can try something like this:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Me.DateTimePicker1.Format = DateTimePickerFormat.Custom

Me.DateTimePicker1.CustomFormat = " "

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.DateTimePicker1.Format = DateTimePickerFormat.Custom

Me.DateTimePicker1.CustomFormat = " "

End Sub

Private Sub DateTimePicker1_DropDown(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DateTimePicker1.DropDown

Me.DateTimePicker1.CustomFormat = "yyyy/MM/dd"

End Sub

Private Sub DateTimePicker1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles DateTimePicker1.KeyDown

If e.KeyCode = Keys.Delete Then

Me.DateTimePicker1.CustomFormat = " "

ElseIf Me.DateTimePicker1.CustomFormat = " " AndAlso _

(e.KeyValue >= 48 AndAlso e.KeyValue <= 57) OrElse _

(e.KeyValue >= 96 AndAlso e.KeyValue <= 105) _

Then

Me.DateTimePicker1.CustomFormat = "yyyy/MM/dd"

End If

End Sub
--

HTH

Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"XmlAdoNewbie" <er************@cowaninsurancegroup.com> wrote in message
news:c9**************************@posting.google.c om...
Hi All,
I am wondering if it is possible to allow nulls or empty strings when
it comes to the datetimepicker control. I have an app with a few
datetimepickers on it and there are some instances when i don't want a
date to show at all but the datetimepickers always have at least
todays date in it so when i go to press the save button on my app
there is always a date stored in the retrieved field. Is there a way
to say "hey i don't want a date stored in this field, i want "" or
null"
thanks
Erin

Nov 16 '05 #3
Hi Eric,
Thanks so much for your post. It works in that it shows a blank date in
the date time picker however when i go to retrieve the value out of the
date time picker it still gives me today's date. I would like the value
to be an empty string if the date time picker is showing a blank, is
this possible??
Thanks
Erin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4
You can try something like this:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Me.DateTimePicker1.Format = DateTimePickerFormat.Custom

Me.DateTimePicker1.CustomFormat = " "

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.DateTimePicker1.Format = DateTimePickerFormat.Custom

Me.DateTimePicker1.CustomFormat = " "

End Sub

Private Sub DateTimePicker1_DropDown(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DateTimePicker1.DropDown

Me.DateTimePicker1.CustomFormat = "yyyy/MM/dd"

End Sub

Private Sub DateTimePicker1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles DateTimePicker1.KeyDown

If e.KeyCode = Keys.Delete Then

Me.DateTimePicker1.CustomFormat = " "

ElseIf Me.DateTimePicker1.CustomFormat = " " AndAlso _

(e.KeyValue >= 48 AndAlso e.KeyValue <= 57) OrElse _

(e.KeyValue >= 96 AndAlso e.KeyValue <= 105) _

Then

Me.DateTimePicker1.CustomFormat = "yyyy/MM/dd"

End If

End Sub
--

HTH

Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"XmlAdoNewbie" <er************@cowaninsurancegroup.com> wrote in message
news:c9**************************@posting.google.c om...
Hi All,
I am wondering if it is possible to allow nulls or empty strings when
it comes to the datetimepicker control. I have an app with a few
datetimepickers on it and there are some instances when i don't want a
date to show at all but the datetimepickers always have at least
todays date in it so when i go to press the save button on my app
there is always a date stored in the retrieved field. Is there a way
to say "hey i don't want a date stored in this field, i want "" or
null"
thanks
Erin

Nov 16 '05 #5
Hi Eric,
Thanks so much for your post. It works in that it shows a blank date in
the date time picker however when i go to retrieve the value out of the
date time picker it still gives me today's date. I would like the value
to be an empty string if the date time picker is showing a blank, is
this possible??
Thanks
Erin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6
You may validate if Me.DateTimePicker1.CustomFormat = " "

--

HTH

Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"Erin Sebastian" <er************@cowaninsurancegroup.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
Hi Eric,
Thanks so much for your post. It works in that it shows a blank date in
the date time picker however when i go to retrieve the value out of the
date time picker it still gives me today's date. I would like the value
to be an empty string if the date time picker is showing a blank, is
this possible??
Thanks
Erin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #7
You may validate if Me.DateTimePicker1.CustomFormat = " "

--

HTH

Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"Erin Sebastian" <er************@cowaninsurancegroup.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
Hi Eric,
Thanks so much for your post. It works in that it shows a blank date in
the date time picker however when i go to retrieve the value out of the
date time picker it still gives me today's date. I would like the value
to be an empty string if the date time picker is showing a blank, is
this possible??
Thanks
Erin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #8

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

Similar topics

5
by: Adrian Parker | last post by:
Hi. I have a date time picker in my program which uses ADO to read from an Access database. It works perfectly, unless the database is empty (no records) when opened. When you try to open an...
7
by: XmlAdoNewbie | last post by:
Hi All, I am wondering if it is possible to allow nulls or empty strings when it comes to the datetimepicker control. I have an app with a few datetimepickers on it and there are some instances...
2
by: Darhl Thomason | last post by:
I'm converting my Access 2003 VBA app. I have a number of date fields in my db that I want to use the date/time picker control with, but if there is no entry in my database, I want the date/time...
4
by: Michel Posseth [MCP] | last post by:
I have a problem with the date time picker validate event wich i believe is a bug How to reproduce : throw on a form a date time picker control and a textbox control select the validating...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.