dannyhop
asked on
I need a way to GoTo a specified line number in a RichTextBox display in C#
I need a way to GoTo a specified line number in a RichTextBox display in C#.
In other words&
I would like the line number requested to become the 1st line displayed in the visabe (on-screen) RichTextBox.
I seem to be able to set the selection using the following
int lineno = 20; // example: 20 is a legal line number in the Richtextbox.
int index = this.scriptContainer.GetFi rstCharInd exFromLine (lineno);
this.scriptContainer.Selec t(index, 1);
However the RTB control does not seem to automatically jump to display the selection in the visable RichTextBox.
What Am I missing?
I cant seem to find a simple GoTo line number ;-)
Thank you for your kind assistance.
dannyhop
In other words&
I would like the line number requested to become the 1st line displayed in the visabe (on-screen) RichTextBox.
I seem to be able to set the selection using the following
int lineno = 20; // example: 20 is a legal line number in the Richtextbox.
int index = this.scriptContainer.GetFi
this.scriptContainer.Selec
However the RTB control does not seem to automatically jump to display the selection in the visable RichTextBox.
What Am I missing?
I cant seem to find a simple GoTo line number ;-)
Thank you for your kind assistance.
dannyhop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All I really needed was to add .ScrollToCaret().
This now works...
int lineno = 20; // example: 20 is a legal line number in the Richtextbox.
int index = this.scriptContainer.GetFi
this.scriptContainer.Selec
this.scriptContainer.Scrol
And to think, I have used ScrollToCaret() before. I must be losing it ;-)
Thanks... The last line in your example was what I was missing....
Anybody know of a good RichTextBox tutorial?