Thanks for keeping in touch. The thing is when we call :
charIndex += textBox.Lines[i].Length + Environment.NewLine.Length;
It does a sum operatioin on textBox.lines + 2.
let's say my textBox has 10 lines and every line has some characters or
nothing ... now each iteration the value
of charIndex is being increased. Here I have text box with 10 lines; after
running the loop charIndex isn't even equal to 10 (max line number in
textbox)
only after first iteration the value of charIndex is 15 which is greater
than 10.
then how can I send the cursor to 39 (value of charIdnex after exiting the
loop)?
Or there is something that I can't get but since I've used the code you
pointed.
Again I apprecaite your concern.
"C# Learner" <cs****@learner.here> wrote in message
news:a4********************************@4ax.com...
"Ramsin Savra" <rs****@otxresearch.com> wrote:
Thanks for help but doesn't work it generates number much bigger than
textbox.lines. I have defined 10 lines for it but the code calculates
numberof characters in every line so it's not the logic I'm looking for.
regards
That's the whole point. It gets the *character index* of the start of
a line.
This character index is then used in "textBox.SelectionStart =
charIndex".
You can't select a line with a *line index*, as far as I know.