Hi All
Is it possible to display null values (empty) in datatimepicker control.
If the value does not exist in the database , it should display blank .
./Thanks in advance
PRash
|
| Prashweenet Wednesday, October 24, 2007 5:31 AM |
Hi,
One workaround is that you use three domainUpDown. One for day,another for month and last for year.
In all of them you can have one item blank.
If i find any better solution I will inform you that.
Regards,
Manju Sandhu |
| Manju Sandhu Wednesday, October 24, 2007 9:16 AM |
Hi, Prashweenet,
Based on my understanding, you want to find a DateTimerPicker which can support null value, don't you?
Well, the standard DateTimePicker does not support this feature,
however there are a lot of custom control which can support it.
http://www.codeproject.com/useritems/ketan.asp
http://www.codeproject.com/cs/miscctrl/Nullable_DateTimePicker.asp
http://www.codeproject.com/cs/miscctrl/extended_datetimepicker.asp
And Manju Sandhu is right, you can use a MonthCalendar, a DropDownBox to build your own DateTimePicker which can support null value.
Hope this helps,
Regards
|
| Yu Guo �MSFT Friday, October 26, 2007 8:45 AM |
Hi Preshweenet,
This is not possible.
DateTimePicker.Value must be between DateTime.MinValue and DateTime.MaxValue.Otherwise exception will be raised.
Regards,
Oleh. |
| Oleh Svintsitskyy Wednesday, October 24, 2007 6:11 AM |
Hi,
Is it not possible to display null values in datetimepicker.
Datetimepicker always show some valid datetime.
Regards,
Manju Sandhu |
| Manju Sandhu Wednesday, October 24, 2007 6:19 AM |
Hi again
Is there any other control which serve the same purpose of DataTimepicker with the null value support
/Thansk in adance
PRash
|
| Prashweenet Wednesday, October 24, 2007 8:04 AM |
Hi,
One workaround is that you use three domainUpDown. One for day,another for month and last for year.
In all of them you can have one item blank.
If i find any better solution I will inform you that.
Regards,
Manju Sandhu |
| Manju Sandhu Wednesday, October 24, 2007 9:16 AM |
Hi, Prashweenet,
Based on my understanding, you want to find a DateTimerPicker which can support null value, don't you?
Well, the standard DateTimePicker does not support this feature,
however there are a lot of custom control which can support it.
http://www.codeproject.com/useritems/ketan.asp
http://www.codeproject.com/cs/miscctrl/Nullable_DateTimePicker.asp
http://www.codeproject.com/cs/miscctrl/extended_datetimepicker.asp
And Manju Sandhu is right, you can use a MonthCalendar, a DropDownBox to build your own DateTimePicker which can support null value.
Hope this helps,
Regards
|
| Yu Guo �MSFT Friday, October 26, 2007 8:45 AM |
You can use the checbox property of the datetimepicker
When you save to your database you do
Dpar.IsNullable = True
Dpar.Value = IIf(DTP1.C hecked,DTP1.Value, DBNull.Value)
When youread from your database you do
Me .DTP1.Value = IIF(tabla.Rows(0)(row(0)("field").ToString)
Is DBNull.Value, Date.Now, tabla.Rows(0)(row(0)("field").ToString))
Me.DTP1.Checked = Not (tabla.Rows(0)(row(0)("field").ToString) Is DBNull.Value)
|
| AndresCabral Monday, April 14, 2008 2:20 PM |
I have had the similar problem. I did the workaround is that, when the user inputs nothing in the datetime field va lues, I make the datetime variable to maxvalue and save it to database, and when retrieiving from the database, I checked if its max value then display nothing.
|
| Farhan.Khan Monday, April 14, 2008 2:29 PM |
For set a empty value in a DateTimePicker control use the CustomFormat: | this.dateTimePicker.CustomFormat="";//useaspace | | this.dateTimePicker.Format=System.Windows.Forms.DateTimePickerFormat.Custom; |
Best regards,
Sergiu |
| Sergiu Dudnic Tuesday, January 20, 2009 11:35 AM |