Page 1 of 1

How to make a particular line to topmost?

Posted: Wed Mar 18, 2020 11:07 am
by Jim Knopf
How can I make the line where the cursor is, to the topmost of a TRichViewEdit?

Re: How to make a particular line to topmost?

Posted: Wed Mar 18, 2020 2:53 pm
by Sergey Tkachenko
Do you want to scroll to show the caret on top?

The simplest code is:

Code: Select all

var
  R: TRect;
  ItemPart: Integer;

...
 with RichViewEdit1.TopLevelEditor do
  begin
    ItemPart := RVData.GetItemPart(CurItemNo, OffsetInCurItem,
      IsCaretAtTheBeginningOfLine);
    RichViewEdit1.GetItemCoordsEx(RVData, CurItemNo, ItemPart, False, R);
  end;
  RichViewEdit1.ScrollTo(R.Top);

Re: How to make a particular line to topmost?

Posted: Wed Mar 18, 2020 8:11 pm
by Jim Knopf
Perfect, that's it. Thank you!