473,493 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 10741
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
7076
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
518
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
2402
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
4857
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
7119
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
7195
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...
0
7367
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...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
285
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...

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.