以前一直在VB中使用VSFlexGrid控件做网格
或者Delphi中又类似的功能强大的Grid吗?

解决方案 »

  1.   

    给你个例子:
    procedure Thuizong.FormCreate(Sender: TObject);
    var
    col,row,rol,heji:integer;
    begin
     aa:=tvsflexgrid.Create(owner);
     aa.Parent:=panel1;
     aa.Align:=alclient;
     case flag of
     10..12:label2.Caption:='产品日报'+findapp.SeSkinComboBox1.text;
     50:label2.Caption:='一分厂生产日报';
     51:label2.Caption:='二分厂生产日报';
     52:label2.Caption:='三分厂生产日报';
     53:label2.Caption:='五分厂生产日报';
     54:label2.Caption:='生产日报汇总';
     end;
     huizong.Caption:=label2.Caption;
    case flah of
    1:begin
      with dm do
      begin
      adot1.Close;
      ds1.DataSet:=adot1;
      adot1.Active:=false;
      adot1.TableName:='生产日报';
      adot1.Active:=true;
      aa.AutoResize:=true;
      aa.AllowUserResizing := flexResizeColumns;
      aa.Cols:=adot1.FieldCount-2;
      aa.Rows:=adot1.RecordCount+4;
      aa.Fixedrows:=2;
      aa.FixedCols:=0;
      aa.Rows:=2;
    for row:=0 to aa.Rows-1 do
    begin
      aa.RowHeight[row]:=250;
    end;
    for rol:=0 to adot1.FieldCount-3 do
    begin
    aa.ColWidth[rol]:=1370;
    aa.colAlignment[rol] := flexAlignCenterCenter;
    aa.MergeCells := flexMergeFree;
    aa.Select(0,rol);
    aa.text:='生产日报';
    aa.Select(1,rol);
    aa.text:=adot1.Fields[rol].FieldName;
    aa.MergeCol[rol] :=True;
    aa.MergeCells :=flexMergeRestrictColumns;
    aa.mergerow[0]:=true;
    aa.MergeRow[1]:=true;
    aa.Editable:=2;
    aa.EditCell;
    end;end;
      end
    else case flag of
    10..12,50..54: begin
     zxflag(flag);
     panel2.Visible:=false;
     panel3.visible:=false;
     dm.ADOQ1.Close;
     dm.ADOQ1.SQL.Clear;
     dm.ADOQ1.SQL.Add(fact);
     dm.ADOQ1.Open;
     filldata(aa,dm.ADOQ1);
     end;
     end;
    end;  end;procedure Thuizong.FormDestroy(Sender: TObject);
    begin
    huizong:=nil;
    end;procedure Thuizong.SeSkinButton1Click(Sender: TObject);
    begin
    tabtoadd(aa);
    end;procedure Thuizong.SeSkinButton2Click(Sender: TObject);
    begin
    aa.RemoveItem;
    end;
      

  2.   

    在创建aa之前要声明aa:tvsflexgrid;
    end;procedure heji(vsgrid:tvsflexgrid);
    var
    col,heji,kk,ll:integer;
    he:boolean;
    begin
    ceshi:=vsgrid.Rows-1;he:=false;
    case flag of
    10..12,50..54:
     begin
     try
     for record_flag:=conm to ceshi do
      begin
      if he=true then  begin                       //合计出现过 vsgrid.rows-1
      if record_flag<conm then               //条过合计
      begin
      he:=false;
      continue;
      end;
     end;
      if (vsgrid.TextMatrix[record_flag,0]<>vsgrid.TextMatrix[record_flag+1,0]) then   //判断相邻纪录是否同类型
           begin
            he:=true;        vsgrid.AddItem(vsgrid.textmatrix[record_flag,0]+'合计',record_flag+1);          for col:=5 to vsgrid.Cols-1 do
              begin heji:=0;
                for record_flag2:=conm to record_flag do
                  begin
                    if (trim(vsgrid.TextMatrix[0,col])='周计划') or (trim(vsgrid.TextMatrix[0,col])='上周欠产') or (trim(vsgrid.TextMatrix[0,col])='当日')
                      or (trim(vsgrid.TextMatrix[0,col])='累计') or (trim(vsgrid.TextMatrix[0,col])='欠产') then
                      begin
                //      if (vsgrid.TextMatrix[record_flag,6]='直供机') or (vsgrid.TextMatrix[record_flag,6]='内提机') then
                       heji:=strtoint(vsgrid.TextMatrix[record_flag2,col])+heji;
                       vsgrid.Select(record_flag+1,col);
                       vsgrid.CellForeColor:= clwhite;
                       vsgrid.Text:=inttostr(heji);
                       vsgrid.Select(record_flag+1,11);
                       vsgrid.Text:=vsgrid.TextMatrix[record_flag,11];
                       vsgrid.Select(record_flag+1,12);
                       vsgrid.Text:=vsgrid.TextMatrix[record_flag,12];
                      end;
                  end;
                  vsgrid.Select(record_flag+1,col);
                  vsgrid.CellBackColor:=clhighlight;
              end;
           conm:=record_flag+2;
           ceshi:=vsgrid.Rows;
          end;
         end;
     except
     kk:=vsgrid.Rows-record_flag;
     end;
     kk:=vsgrid.Rows-record_flag;
     if kk>1 then ll:=1 else ll:=0;
        if (record_flag+kk)=vsgrid.Rows then
         begin
          vsgrid.AddItem(vsgrid.textmatrix[record_flag+kk-1,0]+'合计',record_flag+kk);
              for col:=5 to vsgrid.Cols-1 do
              begin heji:=0;
                for record_flag2:=conm to record_flag+ll do
                  begin
                    if (trim(vsgrid.TextMatrix[0,col])='周计划') or (trim(vsgrid.TextMatrix[0,col])='上周欠产') or (trim(vsgrid.TextMatrix[0,col])='当日')
                      or (trim(vsgrid.TextMatrix[0,col])='累计') or (trim(vsgrid.TextMatrix[0,col])='欠产') then
                      begin
                       heji:=strtoint(vsgrid.TextMatrix[record_flag2,col])+heji;
                       vsgrid.Select(record_flag+kk,col);
                       vsgrid.CellForeColor:= clwhite;
                       vsgrid.Text:=inttostr(heji);
                       vsgrid.Select(record_flag+kk,11);
                       vsgrid.Text:=vsgrid.TextMatrix[record_flag+kk-1,11];
                       vsgrid.Select(record_flag+kk,12);
                       vsgrid.Text:=vsgrid.TextMatrix[record_flag+kk-1,12];
                      end;
                  end;
                  vsgrid.Select(record_flag+kk,col);
                  vsgrid.CellBackColor:=clhighlight;
              end;
            exit;
         end;
    //for record_flag=1 to vsgrid.Rows do
    // begin heji:=0;
      // vsgrid.Select(record_flag,6);
     //  if (vsgrid.TextMatrix[record_flag,6]='直供机') or (vsgrid.TextMatrix[record_flag,6]='内提机') then
    //     heji:=strtoint(vsgrid.TextMatrix[record_flag,6])+heji;
    // end;
     end;
     end;
    end;
      

  3.   

    关键是Active控件(原来的VsFlexGrid)在Delphi中不能使用
    提示"无法修改注册信息"