Re: Goto Delphi RichEdit Line?

Posted by Maxwell on July 06, 2005

In Reply to: Goto Delphi RichEdit Line? posted by Madboy on July 06, 2005

: How do you goto a specific line in a Rich Edit box? For example if i displayed an inputbox, and typed 12, how would i goto line 12?

You "go to" a line of a Delphi RichEdit (or a Memo) by setting the SelStart property to the position of the first character of that line. That position is obtained by a Perform function:
RichEdit1.Perform(EM_LINEINDEX, LineNr, 0)

Example code:

procedure TForm1.Button1Click(Sender: TObject);
  LineNr: integer;
  LineNr := StrToInt(Edit1.Text);
  RichEdit1.SelStart := RichEdit1.Perform(EM_LINEINDEX, LineNr, 0);
  Memo1.SelLength := 0;

Related Articles and Replies

Home   FAQ