Change DropDownStyle of RadDateTimePicker

4 posts, 1 answers
  1. Jared
    Jared avatar
    19 posts
    Member since:
    Oct 2015

    Posted 17 Mar 2017 Link to this post

    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.  
  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    2743 posts

    Posted 20 Mar 2017 Link to this post

    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.
  3. Jared
    Jared avatar
    19 posts
    Member since:
    Oct 2015

    Posted 20 Mar 2017 in reply to Dimitar Link to this post

    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.  
  4. Dimitar
    Admin
    Dimitar avatar
    2743 posts

    Posted 21 Mar 2017 Link to this post

    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.
Back to Top