RadDataForm - auto select content when editing

6 posts, 0 answers
  1. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 12 Nov 2013 Link to this post

    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
  2. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 13 Nov 2013 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 15 Nov 2013 Link to this post

    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 >>
  5. Phillip
    Phillip avatar
    3 posts
    Member since:
    Apr 2013

    Posted 30 Apr 2014 Link to this post

    What was the resolution on this, since the rest of us don't have access to this support ticket?
  6. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 30 Apr 2014 Link to this post

    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
  7. Phillip
    Phillip avatar
    3 posts
    Member since:
    Apr 2013

    Posted 30 Apr 2014 in reply to Jeff Link to this post

    Great. Thanks Jeff. I'll give that a shot.
Back to Top
UI for WPF is Visual Studio 2017 Ready