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

Change DropDownStyle of RadDateTimePicker

3 Answers 161 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Jared
Top achievements
Rank 2
Jared asked on 17 Mar 2017, 02:00 PM
Is there a way to change the DropDownStyle of RadDateTimePicker?  Similar to the DropDownStyle property of RadDropDownList.  I want my users to be able to click on any part of the date time picker and drop down the calendar control.  Currently they have to press the down arrow and when they click into the text area of the date time picker they the cursor appears which is unwanted.  In other words I want to be able to click any part of the date time picker control and that makes the calendar appear.  

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 20 Mar 2017, 07:54 AM
Hi Jared,

Thank you for writing.

The following code shows how you can achieve the desired behavior:
public RadForm1()
{
    InitializeComponent();
    radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.ReadOnly = true;
    radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.MouseUp += TextBoxItem_MouseDown;
    radDateTimePicker1.Closing += RadDateTimePicker1_Closing;
}
 
private void RadDateTimePicker1_Closing(object sender, RadPopupClosingEventArgs args)
{
    var calendar = radDateTimePicker1.DateTimePickerElement.CurrentBehavior as RadDateTimePickerCalendar;
    if (!calendar.PopupControl.Bounds.Contains(calendar.PopupControl.PointToClient(Cursor.Position)))
    {
        args.Cancel = args.CloseReason == RadPopupCloseReason.Mouse;
    }
 
}
 
private void TextBoxItem_MouseDown(object sender, MouseEventArgs e)
{
    RadDateTimePickerCalendar calendar = this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;
    if (!calendar.IsDropDownShow)
    {
        calendar.ShowDropDown();
    
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jared
Top achievements
Rank 2
answered on 20 Mar 2017, 03:10 PM
This works great - thanks.  It seems there is a typo on registering the event handler for MouseDown.  You have MouseUp on the left side but MouseUp on the right side.  I went with MouseDown as the event to register to and it seems to be working fine.  
0
Dimitar
Telerik team
answered on 21 Mar 2017, 09:43 AM
Hello Jared,

I was testing with both events and reused the event handler. Nevertheless, I am glad that this is working as expected now.  

Do not hesitate to contact us if you have other questions.
 
Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Jared
Top achievements
Rank 2
Answers by
Dimitar
Telerik team
Jared
Top achievements
Rank 2
Share this question
or