Fail to FindText in RichEdit
I am trying the following :
The index value always return -1. I compare the 4.7 and 4.9 of fastreport's frxRichEdit.pas. The RichEditVersion are 2 and 4. The 4.7 fastreport is work fine. the new version fail to use findtext to search text in RichText. It is the version problem or ...???
Anybody with the same problem, please help....thx....^^
Happy New Year to All.
    r := TfrxRichView (frxReport.FindComponent('Rich'));
    end_index := Length (r.RichEdit.Text);
    index := r.RichEdit.FindText ('{oldstr}', 0, end_index, []);
    r.RichEdit.SelStart := index;
    r.RichEdit.SelLength := Length ('{oldstr}');
    r.RichEdit.SelText := '{newstr}';
The index value always return -1. I compare the 4.7 and 4.9 of fastreport's frxRichEdit.pas. The RichEditVersion are 2 and 4. The 4.7 fastreport is work fine. the new version fail to use findtext to search text in RichText. It is the version problem or ...???
Anybody with the same problem, please help....thx....^^
Happy New Year to All.
Comments
Thanks
Yes. I just create a application with one button and one frxReport.
the code piece is called by button click.
When I click the button, findtext in RichView of report, and then replace the new string into Richview, but the findtext always return -1. that's mean fail to find text.
Thanks
Best Regards,
Akira
then when the rich will be process, and for my job, when I can run the " RichEdit.FindText (....) " & " RichEdit.SelText := 'somestr'; " successfully??
Thanks
a database field or preloaded rtf file?
and show all the code of this pb event.
I am not use the tfrxrichtextobject. I just pre-created TfrxRichView in a report.
Load the report from file.
replace a str in TfrxRichView.RichEdit.Text to new value. for example TfrxRichView.RichEdit = '111{222}333', I find the text {222} by using RichEdit.FindText function, then replace it to {444}.
and then show the report.
How to do it??
Thanks
I just want to change TfrxRichView value before report preview.
Best Regards,
Akira
"I am not use the tfrxrichtextobject. I just pre-created TfrxRichView in a report.
Load the report from file."
what do think a tfrxrichview is?
a richviews richedit text is a 0 based array of lines of text
any how typically.
procedure TForm1.Button9Click(Sender: TObject);
var
r:tfrxrichview;
i : integer;
mytext,s1:string;
begin
frxreport5.LoadFromFile('testrich.fr3');
r:= frxreport5.FindObject('Rich1')as tfrxrichview;
for i := 0 to r.richedit.lines.Count - 1 do
begin
s1 :=r.richedit.lines;
mytext:= stringreplace(s1,'222','888',[]);// delphi function add flag to replace all occurences
r.RichEdit.Lines:= mytext;
end;
frxreport5.ShowReport;
end;
just remember at this point you can only check preloaded text.
If the Rich Text have unicode like "?§??888??", then after I replaced 888 to 222, the "?§"&"??"will become "c" & "a".
Any other way to do the replacement without changing other content in TfrxRichView?
Thanks so much~~
Best Regards,
Akira