Search and Replace problem

General TRichView support forum. Please post your questions here
Post Reply
rafakwolf
Posts: 30
Joined: Tue Sep 27, 2011 11:39 am

Search and Replace problem

Post by rafakwolf »

Hello..

i am trying to search and replace texts...but no success..

using this code :

Code: Select all

procedure SearchAndReplace(rve: TCustomRichViewEdit; old, new: String);
begin
  with rve do
  begin
    SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));

    while SearchText(old, [rvseoDown,rvseoWholeWord]) do
      InsertText(new);
  end;
end;
in the "chat-form" following you can see the problem:

Image

i'm calling the procedure, after text inserted of course...

something wrong ?

thanks alot.[/img]
rafakwolf
Posts: 30
Joined: Tue Sep 27, 2011 11:39 am

Re: Search and Replace problem

Post by rafakwolf »

rafakwolf wrote:Hello..

i am trying to search and replace texts...but no success..

using this code :

Code: Select all

procedure SearchAndReplace(rve: TCustomRichViewEdit; old, new: String);
begin
  with rve do
  begin
    SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));

    while SearchText(old, [rvseoDown,rvseoWholeWord]) do
      InsertText(new);
  end;
end;
in the "chat-form" following you can see the problem:

Image

i'm calling the procedure, after text inserted of course...

something wrong ?

thanks alot.
OBS.:

calling this way

Code: Select all

  add formatted text
...
...
...
SerachAndReplace(MyRvEdit,'<USER>','THEÒS INFORMÁTICA LTDA');
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I read in the private message that your document is read-only.
Yes, all editing methods are blocked in read-only mode, so InsertText does not work.

You can temporary assign ReadOnly=False before executing this code and then restore it back.
But the best solution would be using non-editing methods.
Post Reply