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

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

2 Answers 21 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 26 Sep 2011, 02:10 PM
Hello

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.Add(hostItem)
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
 
                viewMonth()
                Me.Calendar1.Selection.Set(selectedDate)
                 
            Case WinForms.CalendarView.Timetable
                If Calendar1.TimetableSettings.VisibleColumns > 1 Then
                    viewWeek()
                    Me.Calendar1.Selection.Set(selectedDate)
                Else
                    viewDay()
                End If
 
        End Select
 
        setCurrentMonth()
 
 
    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
...CHANGE VALUE HERE...
            End If
 Next


QUESTION 2:

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

Brian

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Vasilev
Telerik team
answered on 29 Sep 2011, 08:57 AM
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
Next

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 >>

0
Brian
Top achievements
Rank 1
answered on 29 Sep 2011, 06:58 PM
Thanks a lot Martin - works as I wanted now
Tags
RibbonBar
Asked by
Brian
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Brian
Top achievements
Rank 1
Share this question
or