Setting cursor at the end of any text of a textbox

c#, cursor-position, textbox, wpf

Solution

For Windows Forms you can control cursor position (and selection) with `txtbox.SelectionStart` and `txtbox.SelectionLength` properties. If you want to set caret to end try this:

txtbox.SelectionStart = txtbox.Text.Length;
txtbox.SelectionLength = 0;

For WPF see this question.

Problem

I have a text box with a displayed string already in it. To bring the cursor to the textbox I am already doing ``` txtbox.Focus(); ``` But how do I get the cursor at the end of the string in the textbox ?

Original source

Related problems