locked
how to move string index on TextBox? RRS feed

  • Question

  • When calling focus on TextBox, key input cursor is located at first index on string.

    TextBox.Focus(FocusState.Programmatic);

    i want to move the key input cursor at last index on string.

    Tuesday, December 30, 2014 2:16 AM

Answers

  • That link is for WPF, not  for Windows Store apps. While the basic concepts are the same pointing to WPF solutions can be confusing in the long run.

    Estmob, you can set the selected range with TextBox.Select(start, length). New text entered will replace the selection so this acts as the input cursor. With a zero length the selection and the cursor are essentially the same.

    To place the cursor at the end set start to the TextBox.Text's length and length to 0:

    myTextBox.Select(myTextBox.Text.Length,0);

    Tuesday, December 30, 2014 7:06 AM

All replies

  • This MSDN link can help with what you are trying to achieve.

    http://developer.nokia.com/community/wiki/Using_Crypto%2B%2B_library_with_Windows_Phone_8

    Tuesday, December 30, 2014 5:36 AM
  • That link is for WPF, not  for Windows Store apps. While the basic concepts are the same pointing to WPF solutions can be confusing in the long run.

    Estmob, you can set the selected range with TextBox.Select(start, length). New text entered will replace the selection so this acts as the input cursor. With a zero length the selection and the cursor are essentially the same.

    To place the cursor at the end set start to the TextBox.Text's length and length to 0:

    myTextBox.Select(myTextBox.Text.Length,0);

    Tuesday, December 30, 2014 7:06 AM
  • Though the link describes the same way(finding the length of text & keeping the length as 0) : 
    tbPositionCursor.Select(tbPositionCursor.Text.Length, 0);

    http://developer.nokia.com/community/wiki/Using_Crypto%2B%2B_library_with_Windows_Phone_8

    Tuesday, December 30, 2014 8:04 AM
  • Though the link describes the same way(finding the length of text & keeping the length as 0)

    Yes (in this instance); however, we have had many posters here very confused by trying to apply WPF docs to Windows Store apps.

    In the future you might include an explanation which indicates the difference and summarizes the solution rather than just a bare link.

    Tuesday, December 30, 2014 6:52 PM
  • Sure, will keep in mind the same :)

    http://developer.nokia.com/community/wiki/Using_Crypto%2B%2B_library_with_Windows_Phone_8

    Wednesday, December 31, 2014 4:55 AM