Fail to FindText in RichEdit

I am trying the following :
    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

  • gordkgordk St.Catherines On. Canada.
    edited 9:47PM
    in what event are you writing this code.
  • edited 9:47PM
    I just write my code in delphi. for example I just to click button to find the text. no write the code on report script.
    Thanks
  • gordkgordk St.Catherines On. Canada.
    edited 9:47PM
    when you want help please answer the question that is asked i can't read your mind as to where and when you are processing this code.
  • edited 9:47PM
    gordk wrote: »
    when you want help please answer the question that is asked i can't read your mind as to where and when you are processing this code.

    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
  • gordkgordk St.Catherines On. Canada.
    edited 9:47PM
    the rich view does not have any text until after it has been processed.
  • edited January 2010
    gordk wrote: »
    the rich view does not have any text until after it has been processed.


    then when the rich will be process, and for my job, when I can run the " RichEdit.FindText (....) " & " RichEdit.SelText := 'somestr'; " successfully??

    Thanks
  • gordkgordk St.Catherines On. Canada.
    edited 9:47PM
    what is your tfrxrichtextobject connected to
    a database field or preloaded rtf file?

    and show all the code of this pb event.
  • edited 9:47PM
    gordk wrote: »
    what is your tfrxrichtextobject connected to
    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
  • gordkgordk St.Catherines On. Canada.
    edited 9:47PM
    this staement makes no sense
    "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.
  • edited 9:47PM
    Yes, Thanks, your code is work. I can replace the string from the lines array. but also have problem is that:

    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
  • edited 9:47PM
    any response??

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.