DateTimePicker Highlight content on enter

2 posts, 0 answers
  1. Mark
    Mark avatar
    66 posts
    Member since:
    Oct 2014

    Posted 19 Jul Link to this post

    I have not found how to select the entire content of a DateTimePicker when it get's focus (OnEnter).  I have done this with a MaskedEditBox, but can't seem to get it to work with this control. Any help would be greatly appreciated.

     

    Thanks

  2. Dimitar
    Admin
    Dimitar avatar
    1877 posts

    Posted 20 Jul Link to this post

    Hello Mark,

    Thank you for writing.

    If you are selecting with the mouse you need to use the MouseUp event to select the text:
     
    public Form1()
    {
        InitializeComponent();
     
        this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.MouseUp += TextBoxItem_MouseUp;
    }
    private void TextBoxItem_MouseUp(object sender, MouseEventArgs e)
    {
     
        radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.SelectAll();
     
    }
     
    private void RadDateTimePicker1_GotFocus(object sender, EventArgs e)
    {
        this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.SelectAll();
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top