RE: RichTextbox scroll to a line
- From: "Mark R. Dawson" <MarkRDawson@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 23 Jul 2005 15:19:06 -0700
Hi Rachel,
one way to do it would be the following:
//have to set focus first on the rich text box for scrolling to work
this.richTextBox1.Focus();
//move the caret to the correct place <IMPO>This is a character position not
line position</IMPO>
this.richTextBox1.SelectionStart = 50;
this.richTextBox1.ScrollToCaret();
I don't think there is a method for setting to caret to an individual line,
so you will have to calculate the position of the caret by knowing how many
characters there are in each line (plus the \r\n)
Hope that helps
Mark.
"Rachel Suddeth" wrote:
> I have the index of a line in the Lines array of a RichTextBox. I would like
> to have it scroll so that line displays at the top. Is there no way to do
> this?
>
> The only way I can see to make it scroll is with ScrollToCaret(). But I
> don't know how to set the "caret" to a particular line.
>
> Any suggestions?
>
> -Rachel
>
>
>
.
- Follow-Ups:
- Re: RichTextbox scroll to a line
- From: Rachel Suddeth
- Re: RichTextbox scroll to a line
- From: Cool Guy
- Re: RichTextbox scroll to a line
- References:
- RichTextbox scroll to a line
- From: Rachel Suddeth
- RichTextbox scroll to a line
- Prev by Date: Re: Data Layer architecture
- Next by Date: RE: followup Q Re: Simple code sample wanted: enum as method parameter
- Previous by thread: RichTextbox scroll to a line
- Next by thread: Re: RichTextbox scroll to a line
- Index(es):
Relevant Pages
|