Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Scroll Caret to Position

Status
Not open for further replies.

Nephila

Programmer
May 14, 2002
13
ZA
I'm pretty new to Delphi, so this may sound like a stupid question, but how can I scroll the caret in a RichEdit to an exact position say something like (line5,char10)?

Thanks for any help!!!
 
You can move it to a particular character by setting SelStart.
You can move to a particular character and force that character to be visible as follows:
Code:
    Memo1.SelStart  := 0;  // move the cursor to the start of the Memo, and
    Memo1.SelLength := 1;  // highlight a character, in order to move the scroll bars back to the top left.
    Memo1.SelLength := 0;  // Then unhighlight the character again.
To move to a particular x,y pos: you could either do some arithmetic based on adding up line lengths, or you could shoot, read Caret to see how you scored, and shoot again. -- Doug Burbidge mailto:doug@ultrazone.com
 
You could also use:

memo1.CaretPos.x := 7; // to set the row number
Memo1.CaretPos.y := 5; // to set the char number





 
The caretpos trick isn't going to apply, as CaretPos is a read-only property :-(

HTH
TonHu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top