Date Picker

  • Thread starter Thread starter Rethish
  • Start date Start date
R

Rethish

Hi All,
I am developing an application in VB.net. I am using .Net Datetime
picker control to manage the date. But I am not able to assign null/Empty
value to the control. I found the property "Checked" to work with this
control..But I cannot use this property for making null dates..
Is there any way to solve this problem?.

Expecting any help or suggestions?

Regards,
Rethish
 
Rethish said:
Hi All,
I am developing an application in VB.net. I am using .Net Datetime
picker control to manage the date. But I am not able to assign null/Empty
value to the control. I found the property "Checked" to work with this
control..But I cannot use this property for making null dates..
Is there any way to solve this problem?.

Expecting any help or suggestions?


What is a "Null" date? ... 1932 1:30 am, 2003 2:39 pm? What is a "Null"
Integer? The point is that DateTime (and Date) is a structure in .NET, not a
Class. This means that there is no true "Null" or Nothing state for the
object, there is only an initial state: 1/1/1900 12:00 AM. So if the object
is = the initial state, then it is empty. You can get around this by
setting the date = New Date( ) or by using the Checked property.

'// Check for a "null" or empty date:
If DateTimeControl.Value.Equals(New Date()) Then
'// the date is empty/null/nothing
End If

'// Set a null/empty date:
DateTimeControl.Value = New Date( )


HTH

~
Jeremy
 
Hello,

Rethish said:
I am developing an application in VB.net. I am using .Net
Datetime picker control to manage the date. But I am not
able to assign null/Empty value to the control. I found the
property "Checked" to work with this control..But I
cannot use this property for making null dates..

Set the 'ShowCheckBox' property to 'True'. If the checkbox is unchecked,
the control can be treated as empty.
 
Hi Jeremy,
When I am trying to set the date as empty for the DateTime picker, I got
the error like the date should be in between min and Max date of the date
picker.
How can I assign DateTimeControl.Value = New Date( ) for a date picker..?

Rethish
 
Rethish said:
Hi Jeremy,
When I am trying to set the date as empty for the DateTime
picker, I got
the error like the date should be in between min and Max date of the
date picker.
How can I assign DateTimeControl.Value = New Date( ) for a date
picker..?

I haven't used the DateTimePicker yet, and maybe the question is better for

microsoft.public.dotnet.framework.windowsforms.controls

(because it is not VB.NET specific) but I'd say that the statement
concerning min/max dates should be followed. Whenever you create a new Date,
the default value is the 1st of january in the year 0001. That's probably
not in the range from DateTimePicker.MinDate to DateTimePicker.MaxDate.
 
Back
Top