how to load text in richobject from delphi

Hello,
Can I load text from external .RTF file in report RICH object form Delphi source?
How to do!?! Please.

Thanks.

Comments

  • edited October 2004
    yep - but due of the (damn) complexity of richtext data, the easiest way to do this is loading the rtf text into a (memory)stream and assign it to the fast report object.
  • edited 5:32PM
    Can u give me example?
    Thanks.
  • edited 5:32PM
    Something like this:
    procedure TForm1.btn1Click(Sender: TObject);
    var
      RichView: TfrxRichView;
      Stream: TMemoryStream;
      Str: string;
    begin
      RichView := TfrxRichView(frxReport1.FindObject('Rich1'));
      if RichView = nil then
        Exit;
      Stream := TMemoryStream.Create;
      try
        Stream.LoadFromFile('Your.rtf');
        SetLength(Str, Stream.Size);
        Stream.Read(Str[1], Stream.Size);
        RichView.RichEdit.Text := Str;
      finally // wrap up
        Stream.Free;
      end;    // try/finally
      if frxReport1.PrepareReport then
        frxReport1.ShowPreparedReport;
    end;
    
  • edited 5:32PM
    Great.... Thank u very much....

    Now I have problem with FastReport maybe is BUG. When load text in RichText object, text show out of range of page. Please see a picture.rich-bug.JPG
  • edited 5:32PM
    You should probably set the Stretched property of Rich and its band, also AllowSplit for the band.
  • edited 5:32PM
    I tried this and it is working well:

    ((TfrxMemoView*)frxReport1->FindObject("Memo1"))->Text = "Hello World";
    ((TfrxRichView*)frxReport1->FindObject("Rich1"))->RichEdit->Text = "Hello World";

Leave a Comment