各位如何动态生成打印的 QRShape QRLabel QRDBText 

解决方案 »

  1.   

    还是用fastreprot吧,它里面的对象都是可以动态控制的。
      

  2.   

    quickreport 不能动态控制吗 
    我在ACTIVE窗体里创建 用..:=TQRLabel.Create(Application) 好像没有Application 
    那位用过
      

  3.   

    var
        i, j: integer;
        QuickRep1: TQuickRep;
        QRLabel1: array of TQRLabel;
        QRLabel2: TQRLabel;
        Item: TListItem;
    begin
      if Tag = 1 then
      begin
        QuickRep1 := TQuickRep.Create(self);
        QuickRep1.Font.Charset := GB2312_CHARSET;
        QuickRep1.Font.Name := '宋体';
        QuickRep1.Font.Size := 10;
        QuickRep1.Bands.HasTitle := True;
        QuickRep1.Bands.HasDetail := True;
        QRLabel2 := TQRLabel.Create(self);
        QRLabel2.Parent := QuickRep1.Bands.TitleBand;
        case Mode of
        0:QRLabel2.Caption := '交班话费清单';
        1:QRLabel2.Caption := '小计话费清单';
        2:QRLabel2.Caption := '统计话费清单';
        end;
        QRLabel2.Font.Size := 14;
        QRLabel2.Left := QuickRep1.Bands.TitleBand.Width div 3;
        SetLength(QRLabel1,ListView1.Columns.Count*ListView1.Items.Count);
        for i:=0 to ListView1.Items.Count-1 do
        begin
          Item := Listview1.Items[i];
          if i = 0 then
          begin
            for j := 0 to Listview1.Columns.Count-1 do
            begin
              QRLabel1[i*Listview1.Columns.Count+j]:= TQRLabel.Create (self);
              QRLabel1[i*Listview1.Columns.Count+j].Parent := QuickRep1.Bands.DetailBand;
              QRLabel1[i*Listview1.Columns.Count+j].Caption :=Trim(Listview1.Columns[j].Caption);
              QRLabel1[i*Listview1.Columns.Count+j].left :=Item.Left+j*Listview1.Column[j].Width; //j*50;
              QRLabel1[i*Listview1.Columns.Count+j].Top := Listview1.Top;
            end;
          end;
          for j := 0 to Listview1.Columns.Count-2 do
          begin
            if j = 0 then
            begin
              QRLabel1[i*Listview1.Columns.Count+j]:= TQRLabel.Create (self);
              QRLabel1[i*Listview1.Columns.Count+j].Parent := QuickRep1.Bands.DetailBand;
              QRLabel1[i*Listview1.Columns.Count+j].Caption :=Trim(Item.Caption);
              QRLabel1[i*Listview1.Columns.Count+j].left :=Item.Left+j*Listview1.Column[j].Width; //j*50;
              QRLabel1[i*Listview1.Columns.Count+j].Top := Item.Top + i;
            end;
            QRLabel1[i*Listview1.Columns.Count+j]:= TQRLabel.Create (self);
            QRLabel1[i*Listview1.Columns.Count+j].Parent := QuickRep1.Bands.DetailBand;
            QRLabel1[i*Listview1.Columns.Count+j].Caption :=Trim(Item.SubItems.Strings[j]);
            QRLabel1[i*Listview1.Columns.Count+j].left :=Item.Left+(j+1)*Listview1.Column[j].Width; //j*50;
            QRLabel1[i*Listview1.Columns.Count+j].Top := Item.Top + i;
          end;
        end;
        QuickRep1.PreviewModal;
      end;
    end;
      

  4.   

    在active中QuickRep1 := TQuickRep.Create(self);都过不去
    大家帮忙
      

  5.   

    为什么我QRLabel2 := TQRLabel.Create(self); 可以执行
    但 QRLabel1[i*Listview1.Columns.Count+j]:= TQRLabel.Create (self); 执行不了
    高手!
      

  6.   

    定义声明QRLabel1[i*Listview1.Columns.Count+j]这个死鬼有没错误?
      

  7.   

    不能那么定义吧!如果要为每个新添的对象命名的话,还是分开的好:tmpQRLabel := TQRLabel.Create (self);
    tmpQRLabel.Name := 'QRLabel' + IntToStr(i*Listview1.Columns.Count+j);