Text alignment in TfrxCrossView

Hi all!

I'm trying to adapt the PrintTable demo for my needs. Is there a way to get different text alignments (right/left justified) for the table columns in the cross view?

Comments

  • gpigpi
    edited 4:11PM
    Try to set text alignment in the TfrxCrossView.OnPrintCell script event
  • edited 4:11PM
    gpi wrote: »
    Try to set text alignment in the TfrxCrossView.OnPrintCell script event
    Thanks for the quick answer, gpi!
    It would be difficult to get the relevant info inside the script, so I tried the OnBeforePrintCell Delphi event instead. My code looks like this:
    procedure TMyForm.frxReport1BeforePrint(c: TfrxReportComponent);
    var
      Cross: TfrxCrossView;
    begin
      if c is TfrxCrossView then
      begin
        Cross := TfrxCrossView(c);
        Cross.OnBeforePrintCell := CrossBeforePrintCell;
      end;
    end;
    
    procedure TMyForm.CrossBeforePrintCell(Memo: TfrxCustomMemoView; RowIndex, ColumnIndex, CellIndex: Integer; const RowValues, ColumnValues, Value: Variant);
    begin
      if <SomeCondition> then
        Memo.Align := baRight
      else
        Memo.Align := baLeft;
    end;
    
    However the cells are still unaligned in the preview although the Memo.Align lines are executed.
  • gpigpi
    edited 4:11PM
    Works OK in the script
    procedure Cross1OnPrintCell(Memo: TfrxMemoView; RowIndex, ColumnIndex, CellIndex: Integer; RowValues, ColumnValues, Value: Variant);
    begin
        if ColumnIndex = 0 then
        Memo.HAlign := haRight
      else
        Memo.HAlign := haLeft;                                       
    end;
    
  • edited 4:11PM
    gpi wrote: »
    Works OK in the script
    procedure Cross1OnPrintCell(Memo: TfrxMemoView; RowIndex, ColumnIndex, CellIndex: Integer; RowValues, ColumnValues, Value: Variant);
    begin
        if ColumnIndex = 0 then
        Memo.HAlign := haRight
      else
        Memo.HAlign := haLeft;                                       
    end;
    
    Ah, HAlign, not Align! Thanks!

Leave a Comment