R Ramsin Savra Feb 2, 2004 #1 Hi How to move the cursor to line 6 (or any line) in a TextBox control ? thx
A AirPete Feb 3, 2004 #2 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
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
R Ramsin Savra Feb 4, 2004 #3 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 Click to expand... Click to expand...
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 Click to expand... Click to expand...
A AirPete Feb 4, 2004 #4 What doesn't it do? It works fine on my machine. - Pete 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 Click to expand... Click to expand... Click to expand...
What doesn't it do? It works fine on my machine. - Pete 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 Click to expand... Click to expand... Click to expand...
C C# Learner Feb 4, 2004 #5 AirPete said: What doesn't it do? It works fine on my machine. Click to expand... Works fine here too...
AirPete said: What doesn't it do? It works fine on my machine. Click to expand... Works fine here too...