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

Show the datetimepicker in dropped down mode when a gridview cell is selected

1 Answer 204 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 20 Jun 2012, 04:53 PM
I have a RadGridView in Winforms and a date time cell which when clicked will show the text edit mode and a drop down arrow to the right. On clicking the drop down arrow the nice calendar date picker shows.

I'm trying to get the calendar to show straight away but can't find a method on the calendar object. My current code is as follows;

Private Sub OrderGridView_CellEditorInitialized(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles OrderGridView.CellEditorInitialized
    Console.WriteLine("Editor init: {0}", e.ToString())
 
    Dim editor = TryCast(OrderGridView.ActiveEditor, RadDateTimeEditor)
    If (editor IsNot Nothing) Then
        Dim calendar = DirectCast(editor.EditorElement, RadDateTimeEditorElement)
        calendar.GetCurrentBehavior().DateTimePickerElement.Visibility = Telerik.WinControls.ElementVisibility.Visible
        calendar.PerformClick()
        calendar.Select()
    End If
 
End Sub


Is there a way to do this? Perhaps if not possible, I'll fake a click to the drop down button.

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 25 Jun 2012, 11:18 AM
Hello Terry,

Thank you for contacting Telerik support.

You should call ShowPopup method in order to show the calendar portion of the DateTimePicker Editor.
Please refer to code below and to the sample project.
Private Sub OrderGridView_CellEditorInitialized(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles OrderGridView.CellEditorInitialized
 
    Console.WriteLine("Editor init: {0}", e.ToString())
 
    Dim editor = TryCast(OrderGridView.ActiveEditor, RadDateTimeEditor)
 
    If (editor IsNot Nothing) Then
 
        Dim calendar = DirectCast(editor.EditorElement, RadDateTimeEditorElement)
 
        TryCast(calendar.GetCurrentBehavior(), RadDateTimePickerCalendar).Calendar.LoadElementTree()
 
        AddHandler TryCast(calendar.GetCurrentBehavior(), RadDateTimePickerCalendar).PopupControl.PopupClosing, AddressOf canClose
 
        TryCast(calendar.GetCurrentBehavior(), RadDateTimePickerCalendar).ShowDropDown()
 
    End If
End Sub
 
Private Sub canClose(sender As Object, args As RadPopupClosingEventArgs)
    args.Cancel = args.CloseReason = RadPopupCloseReason.AppFocusChange
End Sub

I hope this helps.

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