Scroll selection to center after calling SearchText method
Scroll selection to center after calling SearchText method
Hello, The SearchText method selects the found text and scrolls it to view. Is it possible to scroll the selected text to center of RichViewEdit?
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Scroll selection to center after calling SearchText method
You can implement it using undocumented methods:
Code: Select all
// searching for 'a' and centering the found line vertically
var
rve: TCustomRichViewEdit;
ItemNo, Offs: Integer;
begin
RichViewEdit1.BeginUpdate;
if RichViewEdit1.SearchText('a', [rvseoDown]) then
begin
rve := RichViewEdit1.TopLevelEditor;
ItemNo := rve.CurItemNo;
Offs := rve.OffsetInCurItem;
rve.RVData.Item2DrawItem(ItemNo, Offs, ItemNo, Offs);
RichViewEdit1.ScrollToDrawItem(rve.RVData, ItemNo, True);
end;
RichViewEdit1.EndUpdate;
end;