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

Wrong date selected in double click

1 Answer 166 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Inger Marie
Top achievements
Rank 1
Inger Marie asked on 22 Dec 2011, 02:37 PM
I have a raddatetimepicker in my application. When I open the pop-up it will show the days of the months.. and the last days of the last month and the first days of the next month.

Lets say that the date already selected i 24th november 2011. When I open the pop-up, I can select the 2nd december without changing the month. That works.. but if I double-click on the 2nd december, it chooses 30th december, not 2nd.

I have implemented the mousedoubleclick event:

  void RadDateTimePicker_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (((RadDateTimePicker)sender).IsDropDownOpen)
                ((RadDateTimePicker)sender).IsDropDownOpen = false;
            else if (((RadDateTimePicker)sender).SelectedValue == null)
                ((RadDateTimePicker)sender).SelectedValue = DateTime.Now;
            e.Handled = true;
        }

The selected value is the 30th december, not the 2nd december in the mousedoubleclick-handler.

It there any way to make sure that a doubleclick selects the intended date (and closes the pop-up-dialog)?

This error only appears when the popup dialog shows a specific month and I click on the "grey-out" dates in the surounding months.

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 23 Dec 2011, 12:14 PM
Hello Inger,

The problem is that when you close the dropdown like this, it doesn't switch to the next month and the wrong date is selected. I would suggest to set also DisplayDate property and use PreviewMouseDoubleClick event. I've attached my test project to show the needed changes, please download it and give it a try.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
DateTimePicker
Asked by
Inger Marie
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or