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

RadDataForm - auto select content when editing

5 Answers 102 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 12 Nov 2013, 09:18 PM
I'm using a RadDataForm with auto-generated fields and field edit controls. In case it's important, the RadDataForm is bound to a DataView. Due to the datatypes involved, most of the auto-generated edit controls are simply text boxes.  When I tab from one editable field to another, I'd expect the current contents to be "selected" so I could either 1) tab past an existing value or 2) quickly change it.

Currently however, the insert cursor is placed in the field - sometimes at the end of the existing data and sometimes at the beginning (I haven't determined what controls its location). So, if I just press <TAB> to advance to the next field and start typing some new data, it's *added* (either prepended or appended based on cursor position) to the existing data instead of overwriting it as I'd expect.

How can I force the current contents of each text box to be automatically selected when the control receives focus?

Jeff

5 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 13 Nov 2013, 03:38 PM
I just noticed that the described behavior is exhibited in the Telerik-provided RadDataForm demos also. To me, this is not a desirable default behavior, as it make editing the form's content much more cumbersome than necessary...

Jeff
0
Yoan
Telerik team
answered on 15 Nov 2013, 04:03 PM
Hello Jeff,

I have just replied to your support ticket on the same topic.  

Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Phillip
Top achievements
Rank 1
answered on 30 Apr 2014, 04:39 PM
What was the resolution on this, since the rest of us don't have access to this support ticket?
0
Jeff
Top achievements
Rank 1
answered on 30 Apr 2014, 04:45 PM
The suggested solution was to simply subscribe to the GotFocus event of the TextBox and handle the selection in the event handler.  So, basically, just this:

private void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
    (sender as TextBox).SelectAll();
}

Seems to work as desired...

Jeff
0
Phillip
Top achievements
Rank 1
answered on 30 Apr 2014, 04:46 PM
Great. Thanks Jeff. I'll give that a shot.
Tags
DataForm
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Yoan
Telerik team
Phillip
Top achievements
Rank 1
Share this question
or