print stringgrid

hello,

I'a trying to print a stringgrid using the example code in the demo pack.

But I don't inderstand if the name of the cross view changes (for example, my Tfrxcrossview is cross1)
Because I have 2 crossview (cross1 and cross2) on my report, and I want to have the good data on the good cross view !

Could you help me to adapt this code with a named Tfrxcrossview ?
procedure TForm1.frxReport1BeforePrint(c: TfrxReportComponent);
var
  Cross: TfrxCrossView;
  i, j: Integer;
begin
  c.Name:='cross1'; // I tried this but it's not Ok !!!
  if c is TfrxCrossView then
  begin
    Cross := TfrxCrossView(c);
    for i := 1 to 16 do
      for j := 1 to 16 do
        Cross.AddValue([i], [j], [StringGrid1.Cells[i - 1, j - 1]]);
  end;
end;

regards

Comments

  • gpigpi
    edited 2:27PM
    procedure TForm1.frxReport1BeforePrint(c: TfrxReportComponent);
    var
      Cross: TfrxCrossView;
      i, j: Integer;
    begin
      if c.Name = 'Cross1' then 
      if c is TfrxCrossView then
      begin
        Cross := TfrxCrossView(c);
        for i := 1 to 16 do
          for j := 1 to 16 do
            Cross.AddValue([i], [j], [StringGrid1.Cells[i - 1, j - 1]]);
      end;
    end;
    
  • edited 2:27PM
    hello,

    thank you
    it's working fine now [img]style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> Another question: Is it possible to put a name on the colum and row ? For example if we take the same example as above: how I can do to set 'C1, C2,C3, ....C16' for colum title and 'R1,R2,R3...R16 for row title ? regards[/img]
  • gpigpi
    edited 2:27PM
    See PrintTable demo

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.