|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to set the default value of a date picker to nothing (blank)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. 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/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformserrorproviderclasstopic.asp I hope this helps, Cor Eduardo78 wrote:
> I need to have a control where the default value equals nothing, and I don't believe it is possible to do this with the DateTimePicker -- it> 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. always displays a date. -- (O) e n o n e "Eduardo78" <Eduard***@discussions.microsoft.com> schrieb: You may want to set the 'ShowCheckBox' property to 'True' and use the >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. 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/> |
|||||||||||||||||||||||