Tab in the Date selector(Calendar of RadDatePicker) should input the selected date and take you to the next field.

3 posts, 0 answers
  1. Shimoli
    Shimoli avatar
    16 posts
    Member since:
    May 2011

    Posted 22 Aug 2012 Link to this post

    In the date selector, the tab key should select the date and move the focus to the next field.  Currently tab moves to the next day of the month in the date selector and keeps the date selector open as focus on Calendar control instead of Date Picker.

    I have created custom DatePicker control which has been inherited by RadDatePicker. In DropDownOpened event, I have set Today's date, if Selected value=null and on KeyUp event, I want to move to the next control, if user has pressed Tab/Escape event. Esc is going to work. But in case of Tab KeyUp, it is not going into the KeyUp event (as focus is on Calendar control). I want to get Calendar control's object and on its KeyUp event, I want to close calendar and I want to move on next control.

    Let me know what to do.

    Here  I have paste my custom control.
     public class CDatePicker : RadDatePicker
        {
            #region Constructor

            public CDatePicker()
                : base()
            {
                this.DateTimeWatermarkContent = string.Empty;
                this.DropDownOpened += new RoutedEventHandler(CDatePicker_DropDownOpened);
            }
            #endregion

            #region Events

            protected override void OnKeyDown(KeyEventArgs e)
            {
                if (this.IsDropDownOpen)
                {
                    if (e.Key == Key.Escape)
                    {
                        this.IsDropDownOpen = false;
                    }

                    if (e.Key == Key.Tab)
                    {
                        this.IsDropDownOpen = false;
                    }
                }

                base.OnKeyDown(e);
            }

           void CDatePicker_DropDownOpened(object sender, RoutedEventArgs e)
            {
                if (this.SelectedDate == null)
                {
                    this.SelectedValue = DateTime.Now.Date;
                }
            }

            #endregion
    }

  2. Georgi
    Admin
    Georgi avatar
    348 posts

    Posted 27 Aug 2012 Link to this post

    Hello Shimoli,

    The KeyUp event is fired only for the DateTimePicker, but not for the Calendar part of it. So you need to hook up to the KeyUp event of the Calender. Hot to achieve that you can see in the attached project. Once you hook up to it you can implement your custom logic.
    Hope this will help.


    Kind regards,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Shimoli
    Shimoli avatar
    16 posts
    Member since:
    May 2011

    Posted 29 Aug 2012 Link to this post

    Hi,

    Thanks for the reply. Your example help me out. It's working as required.

    Thanks and Regards,
    Shimoli Shah
Back to Top