Recent

Author Topic: How to search text in Richmemo  (Read 292 times)

Tommi

  • Full Member
  • ***
  • Posts: 237
How to search text in Richmemo
« on: October 21, 2025, 12:11:31 pm »
Hello everyone,
this is my code:
Code: [Select]
  richmemo1.SetFocus;
  if richmemo1.Search(treeview1.Selected.Text,0,length(richmemo1.Text),[soMatchCase,soWholeWord],testo,testoLen) then
  begin
      richmemo1.SelStart := testo;
      richmemo1.SelLength := testoLen;
  end

It works, but the problem is that the selected result is always the last row of the Richmemo control. I'd like that highlighted text wold be positioned in the center.

How colud I do ?

Thank you

CM630

  • Hero Member
  • *****
  • Posts: 1523
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to search text in Richmemo
« Reply #1 on: October 21, 2025, 03:23:24 pm »
Maybe move the caret to the beginning of the selection, then scroll a few lines down (in this example 8 ) and then restore the selection.

Code: Pascal  [Select][+][-]
  1.   RichMemo1.SelStart := testo;
  2.   RichMemo1.CaretPos := point(0,RichMemo1.CaretPos.Y+8);
  3.   RichMemo1.SelStart := testo;
  4.   RichMemo1.SelLength := testolen;
« Last Edit: October 21, 2025, 03:25:26 pm by CM630 »
Лазар 4,2 32 bit (sometimes 64 bit); FPC3,2,2

 

TinyPortal © 2005-2018