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

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

2 Answers 38 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Shimoli
Top achievements
Rank 1
Shimoli asked on 22 Aug 2012, 06:21 AM

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 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 27 Aug 2012, 08:29 AM
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.

0
Shimoli
Top achievements
Rank 1
answered on 29 Aug 2012, 10:33 AM
Hi,

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

Thanks and Regards,
Shimoli Shah
Tags
DatePicker
Asked by
Shimoli
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Shimoli
Top achievements
Rank 1
Share this question
or