DateTimePicker Questions

6 posts, 0 answers
  1. MikeB
    MikeB avatar
    42 posts
    Member since:
    May 2008

    Posted 19 May 2009 Link to this post

    Can the TextBox of the DateTimePicker be set to read only so that the user cannot manually edit any of the date?  I tried using dtp.DateTimePickerElement.TextBoxElement.TextBoxItem.ReadOnly = true, but I was still able to edit the day. 

    When a minDate value is set it appears to the user that they can edit the day and be able to be set the date to a date less than the min date.  Worse yet, say you have a minDate of 5/19/2008 and 5/20/2008 is selected.  If you edit the day to 31 and then edit it again to 15, it will stay at 31 (display = 5/15/2008, value = 5/31/2008).  Very confusing.

    In the constructor, I set the MinDate, NullDate and value of the DateTimePicker = DateTime.Today.  If today is 5/19/2008, using the Picker I cannot select 5/19/2008.  I can only select 5/20/2008 and greater.

    Are there properties that I need to set to avoid this situation?

    Thanks,
    Mike
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 22 May 2009 Link to this post

    Hello MikeB,

    Here is sample code which disables editing in RadDateTimePicker textbox:

        RadMaskTextBox maskBox = (this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.HostedControl as RadMaskTextBox);
                maskBox.Enabled = false;

    I hope this helps.

    Best wishes,
    Boyko Markov
    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. MikeB
    MikeB avatar
    42 posts
    Member since:
    May 2008

    Posted 22 May 2009 Link to this post

    Thanks, that will help.  I would prefer ReadOnly over Enabled but this will work.  I will need to set the foreground color to match the other controls.

    You did not address the MinDate question.  You cannot select the MinDate Date.  Is this normal behavior?

    Thanks,
    Mike
  5. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 25 May 2009 Link to this post

    Hi MikeB,

    I wasn't able to reproduce the second issue. Could you please send me a very simple project which demonstrates the problem or just a code snippet with RadDateTimePicker settings?

    I'm looking forward to your reply.

    Regards,
    Boyko Markov
    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. MikeB
    MikeB avatar
    42 posts
    Member since:
    May 2008

    Posted 01 Jun 2009 Link to this post

    Hi,
    Thanks for the reply.  Sorry for the delay in responding.  I was out last week.

    In the constructor of the form that has the DateTimePicker:
    dtpCallBackDate.MinDate = DateTime.Today.AddDays(-1);

    Now run the appliction, click the DropDown for the DTP and click on the date that would be the MinDate value.  It may set the value (can't remember), but it does not display in the DTP display field.

    Thanks,

    Mike



  7. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 04 Jun 2009 Link to this post

    Hi MikeB,

    Thank you for the feedback. The value is selected and it is not shown in the DTP field because when you set the MinDate property it is automatically synchronized with the NullDate property. Hance when you set the MinDate as value, you actually set the NullDate property. When the current value is equal to the NullDate value then the display field is empty by design. Please write me back again if you need more information.

    All the best,
    Boyko Markov
    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