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

Bind TimePicker to nullable DateTime

4 Answers 350 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 05 Jun 2018, 03:46 PM

With the DateTimePicker, I can bind a nullable DateTime property to NullableValue:

resolvedDateTimePicker.DataBindings.Add("NullableValue", _bindingSource, "DateResolved", true, DataSourceUpdateMode.OnPropertyChanged);

 

Unfortunately the NullableValue property doesn't seem to exist for the TimePicker.

Will this be implemented at some point, and/or how would I bind a DateTimePicker to a nullable DateTime?

4 Answers, 1 is accepted

Sort by
0
Eric
Top achievements
Rank 1
answered on 05 Jun 2018, 05:12 PM
[quote]Eric said:

With the DateTimePicker, I can bind a nullable DateTime property to NullableValue:

resolvedDateTimePicker.DataBindings.Add("NullableValue", _bindingSource, "DateResolved", true, DataSourceUpdateMode.OnPropertyChanged);

 

Unfortunately the NullableValue property doesn't seem to exist for the TimePicker.

Will this be implemented at some point, and/or how would I bind a DateTimePicker to a nullable DateTime?

[/quote]

Sorry, should be:

Will this be implemented at some point, and/or how would I bind a TimePicker to a nullable DateTime?

0
Dimitar
Telerik team
answered on 06 Jun 2018, 08:06 AM
Hello Eric,

The RadTimePicker already supports this. Its Value property type is nullable DateTime and you can directly set it to null:
private void radButton1_Click(object sender, EventArgs e)
{
    radTimePicker1.Value = null;
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Eric
Top achievements
Rank 1
answered on 13 Jun 2018, 01:12 PM

Hi Dimitar,

Thanks for the response, that works great.

It wasn't initially working because I was setting the "formattingEnabled" parameter to false when I was adding the DataBindings.  So I thought that, like the DateTimePicker, you couldn't bind to Value if your DataTime was nullable.  It's a little confusing that they work differently, but it's all good now, thanks.

0
Dimitar
Telerik team
answered on 14 Jun 2018, 09:38 AM
Hi Eric,

Yes, indeed it's a bit confusing, with RadDateTimePicker this was added as a later point and this is why there is another property. Nevertheless, I am glad that his works as expected now and do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Eric
Top achievements
Rank 1
Answers by
Eric
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or