By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,883 Members | 1,272 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,883 IT Pros & Developers. It's quick & easy.

How to set the default value of a date picker to nothing (blank)

P: n/a
I need to have a control where the default value equals nothing, and if an
user enters a value It validates that it is a date, if not show an error
message or advertise that only dates are allowed.
thanks for any suggestion.
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Eduardo,

You mean a textbox with this (code partially from MSDN)
\\\\\
Private Sub nameTextBox1_Validated(sender As Object, e As System.EventArgs)
Handles nameTextBox1.Validated
If IsDate(TextBox1.Text) Then
' Clear the error, if any, in the error provider.
dateErrorProvider.SetError(TextBox1, "")
Else
' Set the error if the name is not valid.
dateErrorProvider.SetError(TextBox1, "Date is wrong")
End If
End Sub
////

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
Eduardo78 wrote:
I need to have a control where the default value equals nothing, and
if an user enters a value It validates that it is a date, if not show
an error message or advertise that only dates are allowed.


I don't believe it is possible to do this with the DateTimePicker -- it
always displays a date.

--

(O) e n o n e
Nov 21 '05 #3

P: n/a
"Eduardo78" <Ed*******@discussions.microsoft.com> schrieb:
I need to have a control where the default value equals nothing, and if an
user enters a value It validates that it is a date, if not show an error
message or advertise that only dates are allowed.


You may want to set the 'ShowCheckBox' property to 'True' and use the
checkbox as a null value indicator (if 'Checked' is 'False', no date is
selected). Notice that the 'ShowCheckBox' property is flawed and thus this
is not the best way.

Nullable DateTimePicker
<URL:http://www.codeproject.com/cs/miscctrl/Nullable_DateTimePicker.asp>

(For a translation to VB.NET, take a look at the comments section of the
page.)

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.