> I want the textbox to goto say line 324 (line 324 is now the first line in
the textbox) when the button is clicked.
What's the command to do this?
You can use the ScrollToCaret() method however you'll need to find the
character position of the line where you want to scroll. This can be done by
using the EM_LINEINDEX API call (fast) or simply by enumerating the lines
(slow). I'm going for the slow one :o)
textBox1.SelectionStart = FindCharacterPos(tb, 324);
textBox1.SelectionLength = 0;
textBox1.ScrollToCaret();
public int FindCharacterPos(TextBox tb, int lineNo) {
if (tb.Lines.Length < lineNo) {
return -1;
}
int pos = 0;
for (int i = 0; i < lineNo; i++) {
pos += tb.Lines[i].Length;
}
return pos;
}
Rgd,
Peter Theill -
http://www.theill.com/