dtp added to Ribbonbar - how to reference from code-behind

3 posts, 1 answers
  1. Brian
    Brian avatar
    45 posts
    Member since:
    May 2008

    Posted 26 Sep 2011 Link to this post


    I have added a telerik dtp to a 'chunk' in a Ribbonbar as follows in the onLoad event of a form.  The purpose is to change the view of a calendar when the value in the dtp is changed.  The code below accomplishes this task as expected:

    Dim dtPicker As New RadDateTimePicker
    dtPicker.ThemeName = "Office2007Blue"
    AddHandler dtPicker.ValueChanged, AddressOf pickerValueChanged
    Dim hostItem As New Telerik.WinControls.RadHostItem(dtPicker)
    hostItem.MinSize = New System.Drawing.Size(150, 50)
    Me.chunkJumpTo.Items(0).Name = "ggPicker"

    The handler that I added is as follows:

    Private Sub pickerValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Dim dtp As RadDateTimePicker = sender
            selectedDate = dtp.Value
            Select Case Me.Calendar1.CurrentView
                Case WinForms.CalendarView.WeekRange
                Case WinForms.CalendarView.Timetable
                    If Calendar1.TimetableSettings.VisibleColumns > 1 Then
                    End If
            End Select
        End Sub

    However, I would like to change the value of the dtp if a new date is clicked on the calendar itself - how can I reference the dtp in the Ribbonbar and change the value that is displayed?

    I found some code from another post - I can find the dtp by doing this (I think) but have not been successful in updating the value...

     For Each ct As RadItem In Me.chunkJumpTo.Items
                If ct.Name = "ggPicker" Then
                End If


    I have several RadImageButtonElements in my Ribbonbar.  I have set the ImageHovered property on several buttons but the new image is not displayed on hover of the button - are there issues with this property? Can you please demonstrate how to display a second image on hover and then revert to this original?

    Thank you

  2. Answer
    Martin Vasilev
    Martin Vasilev avatar
    1061 posts

    Posted 29 Sep 2011 Link to this post

    Hello Brian,

    Thank you for writing.

    Actually, iterating through group's items collection is the right way to access your date-time picker. However, you have to look for a host item instead of trying to directly get a RadDateTimePicker control. Please consider the following code as an example:
    For Each item As RadItem In radRibbonBarGroup2.Items
        If TypeOf item Is RadHostItem Then
            Dim dtp As RadDateTimePicker = DirectCast(DirectCast(item, RadHostItem).HostedControl, RadDateTimePicker)
            dtp.Value = New DateTime(2011, 1, 1)
        End If

    As to your second question, it looks like ImageHovered property does not work as expected. We will address this in one of the future releases. For the time being, you can use MouseEnter and MouseLeave events to change the image. I have updated your Telerik points for bringing this issue to our attention.

    Let me know if you have any additional questions.

    All the best,
    Martin Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Brian
    Brian avatar
    45 posts
    Member since:
    May 2008

    Posted 29 Sep 2011 Link to this post

    Thanks a lot Martin - works as I wanted now
Back to Top