This is a migrated thread and some comments may be shown as answers.

DateTimePicker Highlight content on enter

1 Answer 67 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Mark asked on 19 Jul 2017, 03:54 PM

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

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 20 Jul 2017, 06:29 AM
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.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Answers by
Dimitar
Telerik team
Share this question
or