trichview.com

trichview.support




Re: Replace text in TRichView?


Return to index


Author

Message

Sergey Tkachenko

Posted: 06/19/2002 17:18:43


Yes, viewer does not have methods for text replacing.

You need to iterate through all items in viewer and replace text.


Something like this:


uses CRVData, RVTable;


procedure ReplaceAll(RVData: TCustomRVData; const OldText, NewText: String);

var i,r,c: Integer;

     table: TRVTableItemInfo;

begin

for i := 0 to RVData.Items.Count-1 do

  if RVData.GetItemStyle(i)>=0 then begin // this is a text item

    s := RVData.Items[i];

    // call your function for replacing OldText with NewText in s here

    RVData.Items[i] := s;

    end

  else if RVData.GetItemStyle(i)=rvsTable then begin

    table := TRVTableItemInfo(RVData.GetItem(i));

    for r := 0 to table.Rows.Count-1 do

      for c := 0 to table.Rows[r].Count-1 do

        if table.Cells[r,c]<>nil then

          ReplaceAll(table.Cells[r,c].GetRVData, OldText, NewText);

    table.Changed;

  end;

end;


Call it:


ReplaceAll(RichView.RVData, 'aaa', 'bbb');

RichView.Format;


> how can i replace text in TRichView control? TRichViewEdit control has

some

> methods for that but not TRichView






Powered by ABC Amber Outlook Express Converter