Restrict access to the textbox in DateTimePicker

2 posts, 1 answers
  1. Lasse
    Lasse avatar
    21 posts
    Member since:
    Jul 2011

    Posted 08 Aug 2012 Link to this post

    I want to restrict access, or be able to remove the edit function to the Textbox in the DateTimePicker.
    I tried to hook into the  TextChanging Event of th radDateTimePicker1.DateTimePickerElement.TextBoxElement and set the e.cancel = true. No visible changes was made when trying to edit the text, but it seems like it set some date in behind anyway.

    I could do Enabled = false on the TextBoxElement, but then the control seems locked and I want the user to be able to push the dropdown button and select the date from the calendar. 

    Is there any good way to restrict this access?

    Svein Thomas
  2. Answer
    Stefan avatar
    2891 posts

    Posted 13 Aug 2012 Link to this post

    Hello Svein,

    Thank you for writing.

    Yes, there is a way to do this. You can set the text box to be read only. Here is how to do that:
    radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.ReadOnly = true;

    I hope that this will work for you. Let us know if you have any other questions.

    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. DevCraft banner
Back to Top