DateTimePicker and MinDate

4 posts, 1 answers
  1. Jason Parrish
    Jason Parrish avatar
    87 posts
    Member since:
    Sep 2009

    Posted 09 Dec 2010 Link to this post

    I am encountering 2 issues with the DateTimePicker and MinDate.
    1. I can not select the minimum date from the dropdown picker.  For example, if MinDate is 12/10/2010, I am not able to select that as the date, instead it closes the dropdown and enters nothing in the textbox.  When this occurs, I am unable to type in the textbox until I pick another date.  This does not happen if I click on a date earlier than the MinDate, e.g 12/8/2010.
    2. If I tab into the textbox, I can type in a date earlier than the MinDate.  The value does not change, but the display does.  Not very consistent UX.

    I am using the latest version.

    Thank you!
    --Jason
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 10 Dec 2010 Link to this post

    Hi Jason,

    For your first issue, I can replicate this with the following code and I'd say that this is a bug
    Me.RadDateTimePicker1.Value = New DateTime(2010, 12, 10, 0, 0, 0)
    Me.RadDateTimePicker1.MinDate = New DateTime(2010, 12, 7, 0, 0, 0)
    Me.RadDateTimePicker1.MaxDate = New DateTime(2010, 12, 12, 0, 0, 0)

    however, as a workaround, it doesn't happen if you do this (doesn't clear, just doesn't allow selection for the 7th)
    Me.RadDateTimePicker1.Value = New DateTime(2010, 12, 10, 0, 0, 0)
    Me.RadDateTimePicker1.MinDate = New DateTime(2010, 12, 7, 0, 0, 1)
    Me.RadDateTimePicker1.MaxDate = New DateTime(2010, 12, 12, 0, 0, 0)

    hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jason Parrish
    Jason Parrish avatar
    87 posts
    Member since:
    Sep 2009

    Posted 10 Dec 2010 Link to this post

    Thank you.  I took what you discovered for a workaround, and discovered that a better workaround would be to do this.
      Me.RadDateTimePicker1.Value = New DateTime(2010, 12, 10, 0, 0, 0)
            Me.RadDateTimePicker1.MinDate = New DateTime(2010, 12, 6, 23, 59, 59)
            Me.RadDateTimePicker1.MaxDate = New DateTime(2010, 12, 12, 0, 0, 0)
      Me.RadDateTimePicker1.Value = New DateTime(2010, 12, 10, 0, 0, 0)
            Me.RadDateTimePicker1.MinDate = New DateTime(2010, 12, 6, 23, 59, 59)
            Me.RadDateTimePicker1.MaxDate = New DateTime(2010, 12, 12, 0, 0, 0)

         Me.RadDateTimePicker1.Value = New DateTime(2010, 12, 10, 0, 0, 0)
            Me.RadDateTimePicker1.MinDate = New DateTime(2010, 12, 6, 23, 59, 59)
            Me.RadDateTimePicker1.MaxDate = New DateTime(2010, 12, 12, 0, 0, 0)
         Me.RadDateTimePicker1.Value = New DateTime(2010, 12, 10, 0, 0, 0)
            Me.RadDateTimePicker1.MinDate = New DateTime(2010, 12, 6, 23, 59, 59)
            Me.RadDateTimePicker1.MaxDate = New DateTime(2010, 12, 12, 0, 0, 0)
         Me.RadDateTimePicker1.Value = New DateTime(2010, 12, 10, 0, 0, 0)
            Me.RadDateTimePicker1.MinDate = New DateTime(2010, 12, 6, 23, 59, 59)
            Me.RadDateTimePicker1.MaxDate = New DateTime(2010, 12, 12, 0, 0, 0)
         Me.RadDateTimePicker1.Value = New DateTime(2010, 12, 10, 0, 0, 0)
            Me.RadDateTimePicker1.MinDate = New DateTime(2010, 12, 6, 23, 59, 59)
            Me.RadDateTimePicker1.MaxDate = New DateTime(2010, 12, 12, 0, 0, 0)
    Me.RadDateTimePicker1.Value = New DateTime(2010, 12, 10, 0, 0, 0)
    Me.RadDateTimePicker1.MinDate = New DateTime(2010, 12, 6, 23, 59, 59)
    Me.RadDateTimePicker1.MaxDate = New DateTime(2010, 12, 12, 0, 0, 0)

    This would allow you to select the 7th correctly as expected.

    However, due to the allowing the text to be cleared (as mentioned in my other post), I have replaced the datetimepicker with the masked textbox for now.

    I will continue to find a workaround to prevent the text from being cleared, perhaps preventing the DEL key from being pressed would be the first step.

    Again, thank you.
  5. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 10 Dec 2010 Link to this post

    Glad I could help. Please remember to mark as answer if you found this helpful so others can find the suggestion too.
    All the best
    Richard
Back to Top