Bind TimePicker to nullable DateTime

5 posts, 0 answers
  1. Eric
    Eric avatar
    3 posts
    Member since:
    May 2017

    Posted 05 Jun 2018 Link to this post

    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?

  2. Eric
    Eric avatar
    3 posts
    Member since:
    May 2017

    Posted 05 Jun 2018 in reply to Eric Link to this post

    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?

    Sorry, should be:

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

  3. Dimitar
    Admin
    Dimitar avatar
    2949 posts

    Posted 06 Jun 2018 Link to this post

    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.
  4. Eric
    Eric avatar
    3 posts
    Member since:
    May 2017

    Posted 13 Jun 2018 in reply to Dimitar Link to this post

    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.

  5. Dimitar
    Admin
    Dimitar avatar
    2949 posts

    Posted 14 Jun 2018 Link to this post

    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.
Back to Top