Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3166
Selection behaviour when entering edit mode
posted

When user enters edit mode of a cell, instead of selecting the complete text, I want the cursor to be place at the end of the text. So that the user can start typing. 

How can I achieve this behaviour with XamDataGrid?

  • 34690
    Offline posted

    Hello Bhavesh,

    Just checking in, do you have any questions or concerns on this matter?

    Sincerely,
    Andrew
    Developer Support I
    Infragistics Inc.
    www.infragistics.com/support

     

  • 34690
    Offline posted

    Hello Bhavesh,

    One option to set the cursor at the end of a line of text in a cell in XamDataGrid is to handle the XamDataGrid’s PreviewMouseDown event. In the event handler, get the CellValuePresenter that was clicked on and have it start EditMode.

    I also wrote two int methods that calculate the caret for Numeric and Text editors. These each get the textbox of their respective editor, set an integer value to the length of the text in that textbox, and then return that integer value.

    Back in the PreviewMouseDown event handler, use if statements to determine whether the CellValuePresenter’s editor is either Text or Numeric, then get the editor from the CellValuePresenter, and call the corresponding caret-calculator methods as described above to be set in an integer value. Then set the editor’s selection start equal to that numeric value, and set the SelectionLength to 0 so it doesn’t select the entire text.

    I have attached a sample demonstrating the above.

    Please let me know if you have any questions or concerns.

    Sincerely,
    Andrew
    Developer Support I
    Infragistics Inc.
    www.infragistics.com/support

    XDGCursorAtEndCase.zip