Dynamically change font Style/Size in one row in TfrxRichView

edited June 2017 in FastReport VCL 5
Please for help with this problem. I need change font Style/Size in one row in TfrxRichView. In design mode it is possible. See attachment.
But I can't do it dynamically. I try this

I put frxReport1: TfrxReport on my Form and put TfrxRichView on Page1.

when I click Button1 printer print only second text ' This is size 14'. What is wrong?
Thank you.

procedure TForm1.Button1Click(Sender: TObject);
var R:TfrxRichView;
begin
r:= TfrxRichView(frxReport1.FindObject('Rich1'));
if r<>nil then begin
TfrxRichView®.RichEdit.SelAttributes.Size:=10;
TfrxRichView?®.RichEdit.SelAttributes.Style := [fsBold];
TfrxRichView?®.RichEdit.SelText := 'This is size 10';

TfrxRichView?®.RichEdit.SelAttributes.Size:=14;
TfrxRichView?®.RichEdit.SelAttributes.Style := [fsItalic];
TfrxRichView?®.RichEdit.SelText := ' This is size 14';

frxReport1.PrepareReport(true);
frxReport1.Print;
end;
end;

Comments

  • igyigy
    edited June 2017
    Hello,

    When TfrxRichView Text is 'abcdefghijklabcdefghijkl',

    CheckText := 'abcdefghijkl';
    FoundAt := r.RichEdit.FindText(CheckText, 0, Length(r.RichEdit.Lines.Text), []);
    if FoundAt <> -1 then
    begin
      r.RichEdit.SelStart := FoundAt;
      r.RichEdit.SelLength := Length(CheckText);
    
      r.RichEdit.SelAttributes.Size := 10;
      r.RichEdit.SelAttributes.Style := [fsBold];
      r.RichEdit.SelText := 'This is size 10';
    end;
    
    CheckText := 'abcdefghijkl';
    FoundAt := r.RichEdit.FindText(CheckText, 0, Length(r.RichEdit.Lines.Text), []);
    if FoundAt <> -1 then
    begin
      r.RichEdit.SelStart := FoundAt;
      r.RichEdit.SelLength := Length(CheckText);
    
      r.RichEdit.SelAttributes.Size := 14;
      r.RichEdit.SelAttributes.Style := [fsItalic];
      r.RichEdit.SelText := 'This is size 14';
    end;
    

Leave a Comment