Helpful Information
 
 
Category: Visual Basic Programming
DtPicker : Can we show blank date and time in DtPicker

Thanks for great help rpovided by you.


I am displaying order date and time using DtPicker.

I want to show spaces / blank as default value of DtPicker

How shall I do it ?

With regards
Vikas Athavale

Actually, I am not sure that you can do this. Having something other than a date/time in a datapicker will cause a RTE.

Hi there,

I also had the same problem at work but got around it. What you have to do is set the CheckBox property of the DTPicker to TRUE and then when your form loads, you first set the date to whatever you want (most likely today's date) and then you disable it by setting its value to NULL.

'# First, set date to today... then desables DTPicker #
DTPicker1.Value = Now
DTPicker1.Value = Null

Hope this helps!

Cheers,

Gnu Kemist

I know this topic is really old. Nearly 1 year old.

but I was wondering if it was working and if it was possible to do it in Vb.Net

cause that's what I am doing



Me.DateTimePicker1.Checked = True
Me.DateTimePicker1.Value = Now
Me.DateTimePicker1.Value = System.DBNull.Value


but it's telling me that System.DBNull.Value can't be converted in a Date format.

cause I really need to have my datapicker to null.

I used a little trick to manage this feature: use both a textBox and a datePicker

- The textBox will display the date you select in the datePicker. Can be blank as by default.
- The datePicker is set to it's minimal width to display only the selection arrow
- When a date is selected in the datePicker, the value is transfered to the textBox

Code on the Change event of the datePicker is something like the following:
Private Sub DTPicker1_Change()
TextBox1 = Format(DTPicker1.Value, "dd mmm, yyyy")
End Sub










privacy (GDPR)