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

RadDateTimePicker won't update when used in a hosted item in RadCommandBar

1 Answer 75 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Matt asked on 19 Feb 2012, 06:53 PM
I have a RadDateTimePicker being used inside a hosted item on a RadCommandBar. It shows up fine, and is operational, but if I set the value on the RadDateTimePicker at runtime, it doesn't update. The value property of the RadDateTimePicker does get updated, just not visually on the form. Is there a workaround for this?

I'm using 2011.3.11.1229 of the Telerik controls for WinForms.

Here is the code I'm using to create the RadDateTimePickers and assign them to the hosted item:

        Dim raddatetimepicker_from As Telerik.WinControls.UI.RadDateTimePickerElement
        Dim raddatetimepicker_thru As Telerik.WinControls.UI.RadDateTimePickerElement

        'Create RadDataimePickers
        raddatetimepicker_from = New Telerik.WinControls.UI.RadDateTimePickerElement
        raddatetimepicker_thru = New Telerik.WinControls.UI.RadDateTimePickerElement
        raddatetimepicker_thru.MaxDate = DateTime.Today

        'Format RadDateTimePickers and insert into host
        Dim SizeDTP As New System.Drawing.Size
        SizeDTP.Height = 0
        SizeDTP.Width = 95

        raddatetimepicker_from.MinSize = SizeDTP
        raddatetimepicker_thru.MinSize = SizeDTP

        raddatetimepicker_from.Format = DateTimePickerFormat.Short
        raddatetimepicker_thru.Format = DateTimePickerFormat.Short

        'Assign to hosted item on command bar
        cbhi_from_date.HostedItem = raddatetimepicker_from
        cbhi_thru_date.HostedItem = raddatetimepicker_thru

Here is the code I am using to assign the value, which doesn't cause the RadDateTimePicker to visually update:

        raddatetimepicker_from.Value = DateTime.Now.AddDays(DaysBack * -1)

Any help would be great, don't want to have to fallback to the standard DateTimePicker because I don't believe I can host that in a RadCommandBar. Maybe there is some sort of a "refresh" function I should be using, but I haven't needed to do this in the past when the RadDateTimePicker is just on a regular form instead of inside a hosted item.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 21 Feb 2012, 04:28 PM

Thank you for writing and for the provided details.

Using your code snippet, I was not able to reproduce the issue (see the screenshot)
I am attaching my sample test form - could you modify it in order to reproduce the issue?

I am looking forward to your response.

Kind regards,
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question