Selecting date twice leads to 1980/01/01

6 posts, 1 answers
  1. Stefan Berkmiller
    Stefan Berkmiller avatar
    6 posts
    Member since:
    Nov 2008

    Posted 12 Jun 2009 Link to this post

    Hello Telerik Team,

    I encountered this issue: If you
    - open a RadDateTimePicker
    - select a date
    - open it again and
    - select the same date again,
    the picker will show January the 1st, 1980.

    Have a nice weekend,
    STB


  2. Answer
    Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 15 Jun 2009 Link to this post

    Hello Stefan Berkmiller,

    Thank you for contacting us. When you click on a date that you have been already selected, the date is being deselected. That is why the selected date is set to 1.1.1980. This is the default behavior of the RadCalendar. However, we have managed to create a workaround. Please add the following snippet to your code:

            DateTime selectedDate = DateTime.MinValue;  
      
            void radCalendar1_MouseUp(object sender, MouseEventArgs e)  
            {  
                if (this.radCalendar1.SelectedDates.Count == 0)  
                {  
                    this.radCalendar1.SelectedDate = this.selectedDate;  
                }  
      
                this.selectedDate = this.radCalendar1.SelectedDate;  
            } 

    By handling the MouseUp event you can check whether there is a selected date. If there is no selected date (the date has been already deselected), you can assign the last selected date which in our case is the same date you are trying to deselect. The selectedDate variable holds the value of the last selected date. Thus, if the user clicks multiple times on a single date, it will not be deselected. Please, do not forget to subscribe to this event.

    I hope this helps. If you have further questions, do not hesitate to contact us back.


    Sincerely yours,
    Boryana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan Berkmiller
    Stefan Berkmiller avatar
    6 posts
    Member since:
    Nov 2008

    Posted 15 Jun 2009 Link to this post

    Excellent, thank you very much for your answer.

    However, it would be nice if there would be a possibility to suppress this behavior and to enable a simple single selection mode. Maybe in a future version ;)

    Cheers
  5. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 15 Jun 2009 Link to this post

    Hi Stefan Berkmiller,

    I am glad, we managed to find a solution for the issue. As for your comment, you are right, may be we should reconsider the behavior of RadDateTimePicker. Our team appreciates your feedback. If you have further issues, do not hesitate to contact us.

    Regards,
    Boryana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 Jul 2009 Link to this post

    Hello,

    This solution doesn't seem to work for a raddatetimepicker. Teh solution given seems to be for a radcalendar control. Please can you tell me the solution for a raddatetime picker.
  7. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 06 Jul 2009 Link to this post

    Hi Richard Slade,

    Thank you for contacting us. After our team reconsidered the behavior of radDateTimePicker, we decided to incorporate this as a default behavior of the control in our second release Q2. Now you do not have to add any code to reach this functionality. If you have other issues downloading our new controls, please, refer to this article.

    Greetings,
    Boryana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for WinForms is Visual Studio 2017 Ready