hello, i need to add an text at the end of the cursor position in vb .net i tried
TextBox1.Text = TextBox1.Text.Insert(TextBox1.SelectionStart, "<br>")
it works but the cursor position sets to starting position
hello, i need to add an text at the end of the cursor position in vb .net i tried
TextBox1.Text = TextBox1.Text.Insert(TextBox1.SelectionStart, "<br>")
it works but the cursor position sets to starting position
Just re-set the SelectionStart
property after assigning the text:
Dim insertText = "<br>"
Dim insertPos As Integer = TextBox1.SelectionStart
TextBox1.Text = TextBox1.Text.Insert(insertPos, insertText)
TextBox1.SelectionStart = insertPos + insertText.Length
Add this code after your code to move the caret to the end of your textbox value:
TextBox1.SelectionStart = TextBox1.TextLength
Hello everybody, my name is Julio Cesar P. Magalhaes, live in Brazil, this tip was very good. Thank you.