In .NET, you can easily get the line number of the location of the TextBox cursor (that is, the "current line") using GetLineFromCharIndex and SelectionStart :
var currentLine = textBox1.GetLineFromCharIndex(textBox1.SelectionStart);
Is there a "clean / native" way to set the cursor in the given TextBox line (ie set the "current line")? Or, at least, a “clean / native” way to get the char index of the first character of a given string (something like getCharIndexFromLine , opposite the function I set earlier)?
A way to do this would be to iterate over the first N-1 elements of the Lines TextBox property and summarize their lengths plus the lengths of the lines. Any other idea?
source share