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

Select all text on focus

3 Answers 125 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Fabio
Top achievements
Rank 1
Fabio asked on 20 Nov 2012, 03:09 PM
Hello,
I have a RadAutocompleteBox and I'm looking for a way to select all text on focus.
I looked for SelectAll() method but there's not one. Is there a way to do this?

Thank you in advance
Best regards
Fabio

3 Answers, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 2
answered on 21 Nov 2012, 07:37 AM
0
Heath
Top achievements
Rank 1
answered on 21 Jul 2019, 11:47 PM

Does something like this work (untested - need using Telerik.Windows.Controls;)

var autoComplete = (RadAutoCompleteBox)sender;
var textBox = autoComplete.ChildrenOfType<TextBox>().First();
textBox.SelectAll();

0
Dilyan Traykov
Telerik team
answered on 24 Jul 2019, 08:08 AM
Hello Heath,

Indeed, a similar approach would work with the only specific being that the SelectAll method needs to be invoked through the Dispatcher:

private void RadAutoCompleteBox_GotFocus(object sender, RoutedEventArgs e)
{
    var autoComplete = (RadAutoCompleteBox)sender;
    var textBox = autoComplete.ChildrenOfType<TextBox>().First();
    Dispatcher.BeginInvoke(new Action(() =>
    {
        textBox.SelectAll();
    }));
}

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AutoCompleteBox
Asked by
Fabio
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 2
Heath
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or