I have a memo object in my report, and a need replace "%...%" strings. For example, in Rave Report:
MemoBuf.ReplaceAll('%my_str%', "new string", false);
But, don't exists a method (or property) to replace text, in the FastReport
. How I can do this?
I'm using Fast Report 4.9.72
and Delphi 2010
.
Thanks!
Since there is no StringReplace
in FastReport available I would do it from the Delphi code. It is possible to import functions somehow but this seems to me better arranged. Please note, that in this first example I suppose that the Memo1
exists (you would get an access violation otherwise).
procedure TForm1.Button1Click(Sender: TObject);
var
Memo: TfrxMemoView;
begin
Memo := frxReport1.FindObject('Memo1') as TfrxMemoView;
Memo.Text := StringReplace(Memo.Text, '%my_str%', 'new string', [rfReplaceAll]);
frxReport1.ShowReport;
end;
If you are not sure about component name or type you should use something like this:
procedure TForm1.Button2Click(Sender: TObject);
var
Memo: TfrxMemoView;
Component: TfrxComponent;
begin
Component := frxReport1.FindObject('Memo1');
if Component is TfrxMemoView then
begin
Memo := Component as TfrxMemoView;
Memo.Text := StringReplace(Memo.Text, '%my_str%', 'new string', [rfReplaceAll]);
frxReport1.ShowReport;
end;
end;