This is a migrated thread and some comments may be shown as answers.

DateTime Picker can not be set to blank correctly

3 Answers 660 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 22 Nov 2013, 05:02 AM
I am using your date time picker control with the latest version of the win form controls 2013.3.1016.20

I have the control property ShowUpDown = True

my code is

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
   RadDateTimePicker1.MinDate = New Date(1890, 1, 1)
   RadDateTimePicker1.NullDate = New Date(1890, 1, 1)
   RadDateTimePicker1.NullableValue = Nothing ' New Date(1890, 1, 1)
end sub

under my clear button I have

RadDateTimePicker1.Value = New Date(1890, 1, 1)
RadDateTimePicker1.SetToNullValue()


this whole process of clearing the date seems way to excessive, i took me forever to find you had to set the minDate to the null value date to get this to work at all.
I would expect to be able to clear the control by writing
RadDateTimePicker1.value = nothing
This would be simple, easy and intuitive

Besides that the problem i am having is when the control first loads it shows as blank
if i press the up or down arrow it shows the current date time
when i press my clear button it does clear the control.
but if i then click in the control and then click another control so it loses focus the current date time that appeared after pressing the up or down button comes back and is displayed in the control, and no matter what i try i can not stop it coming back when the control gets and then loses the focus again.

please help, I have spent way to long trying to make this seeming simple vital functionality work correctly

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 26 Nov 2013, 06:40 AM
Hello Scott,

Thank you for contacting Telerik support.

First I want to say that we have a reported issue with RadDateTimePicker where the NullDate and MinDate are set to the same date. You can track the item for status changes and add your vote for it here.

Also in order to display the null text when the control loses focus you just have to set the NullDate to equals the Value date. Basically when this two dates are equal the control will display the null text:
radDateTimePicker1.NullDate = radDateTimePicker1.Value;

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Scott
Top achievements
Rank 1
answered on 26 Nov 2013, 11:32 PM
Hi

This is closer to what we want but is still not working.
I changed my min date so it is not the same as my null date in the form load

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load

        RadDateTimePicker1.MinDate = New Date(1889, 1, 1) ' I changed my min date here
        RadDateTimePicker1.NullDate = New Date(1890, 1, 1)
        RadDateTimePicker1.NullableValue = Nothing ' New Date(1890, 1, 1)

 End Sub

in my clear button i used your suggestion

'RadDateTimePicker1.Value = New Date(1890, 1, 1)
RadDateTimePicker1.NullDate = RadDateTimePicker1.Value
RadDateTimePicker1.SetToNullValue()

If i use the code above (note: commented out first line) then the control does clear correctly
but if the user actual picks the date that was set afterwards (today and same time), then it clears the control for that date.
so I have to set the nulldate to one the user can not actually pick

If I try it with the top line un-commented, then the control clears correctly
but it the user presses the up/down button in the blank control it goes to the date 02/01/1890 not today's date, so then they have to type it or press the up/down arrows a lot of times.
and trying to set the date to today in the ValueChanged event if the control value is too low causes all sorts of issue, circular references.


I figured out a solution as follows, in case anyone else wants to use the date time picker with the up / down controls and needs to clear it
It was to reset the NullDate to a low value in the valueChanged event

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load

        RadDateTimePicker1.MinDate = New Date(1889, 1, 1)
        RadDateTimePicker1.NullDate = New Date(1890, 1, 1)
        RadDateTimePicker1.NullableValue = Nothing ' New Date(1890, 1, 1)

        ' Make sure the first date shown on up/down button press is around today
        RadDateTimePicker1.Value = Now
        RadDateTimePicker1.NullDate = RadDateTimePicker1.Value
        RadDateTimePicker1.SetToNullValue()
    End Sub

 Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click

        RadDateTimePicker1.NullDate = RadDateTimePicker1.Value
        RadDateTimePicker1.SetToNullValue()

    End Sub

 Private Sub RadDateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles RadDateTimePicker1.ValueChanged
        RadDateTimePicker1.NullDate = New Date(1890, 1, 1)
  End Sub


Could you PLEASE log a request to allow setting
RadDateTimePicker1.Value = nothing to clear the date
I don't see any reason why this would not just make everything 100 times easier, with out all this mucking around

0
Dimitar
Telerik team
answered on 29 Nov 2013, 04:13 PM
Hello Scott,

Thank you for writing back.

Thank you also for sharing your solution with the community. 

I think that it is more appropriate to log this as issue rather than feature request. So the issue is logged in our Public Issue Tracking System and you track it for changes and add your vote for it here.

Your Telerik Points have been updated for this report.

Please let me know if there is something else I can help you with.

Regards,
Dimitar
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Scott
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Scott
Top achievements
Rank 1
Share this question
or