R
Ramsin Savra
Hi
How to move the cursor to line 6 (or any line) in a TextBox control ?
thx
How to move the cursor to line 6 (or any line) in a TextBox control ?
thx
AirPete said:The following code should work:
int targetchar = 0;
int targetline = 0; // target line number; zero based.
for(int i =0; i< targetline;++i)
targetchar+=textBox1.Lines.Length + Environment.NewLine.Length;
textBox1.SelectionStart = targetchar;
textBox1.SelectionLength = 0;
textBox1.Focus();
- Pete
Ramsin Savra said:Hi
How to move the cursor to line 6 (or any line) in a TextBox control ?
thx
Ramsin Savra said:Thanks Pete but doesn't function.
AirPete said:The following code should work:
int targetchar = 0;
int targetline = 0; // target line number; zero based.
for(int i =0; i< targetline;++i)
targetchar+=textBox1.Lines.Length + Environment.NewLine.Length;
textBox1.SelectionStart = targetchar;
textBox1.SelectionLength = 0;
textBox1.Focus();
- Pete
Ramsin Savra said:Hi
How to move the cursor to line 6 (or any line) in a TextBox control ?
thx
AirPete said:What doesn't it do?
It works fine on my machine.