现在要在form1的stringgrid1里加入一行,还有一个add按纽,它下面的代码如何写???

解决方案 »

  1.   

    StringGrid1.Rowcount:=StringGrid1.Rowcount+1
      

  2.   

    StringGrid1.Rowcount:=StringGrid1.Rowcount+1
      

  3.   

    StringGrid1.FixedRows:=1;
      StringGrid1.RowCount:=2;  ADO_Goods.Close;
      ADO_Goods.SQL.Clear;
      ADO_Goods.SQL.Text:='Select RYBH,XM ,DoorId, SFZ from tblrywh where XM<>'''' and (RYBH+10000)>='''+('1'+Edit_BH.Text)+''' order by RYBH';
      ADO_Goods.Open;
      ADO_Goods.First;
      i:=1;
      while not  ADO_Goods.Eof do
      begin
        StringGrid1.Cells[0,i]:=ADO_Goods.FieldByName('XM').AsString;
        StringGrid1.Cells[1,i]:=ADO_Goods.FieldByName('DoorId').AsString;
        StringGrid1.Cells[2,i]:='';
        StringGrid1.Cells[3,i]:='';
        StringGrid1.Cells[4,i]:='';
        StringGrid1.Cells[5,i]:='';
        StringGrid1.Cells[6,i]:='';
        StringGrid1.Cells[7,i]:='';
        StringGrid1.Cells[8,i]:='';
        StringGrid1.Cells[9,i]:=ADO_Goods.FieldByName('SFZ').AsString;    ADOJpg.Close;
        ADOJpg.SQL.Clear;
        ADOJpg.SQL.Text:='Select top '+IntEdit1.Text+' * from SDF where XM='''+StringGrid1.Cells[0,i]+''' and CardId='''+StringGrid1.Cells[9,i]+''' and year='''+inttostr(Myyear1)+''' and  month='''+inttostr(Mymonth1)+''' ';
        ADOJpg.Open;
        if  ADOJpg.IsEmpty then
        begin
        end else
        begin
          StringGrid1.Cells[2,i]:=ADOJpg.FieldByName('WaterN').AsString;
          StringGrid1.Cells[5,i]:=ADOJpg.FieldByName('ElectN').AsString;
        end;    ADO_Goods.Next;
        if  i=StrToInt(IntEdit1.Text) then break;
        if  ADO_Goods.Eof=true then break;
        i:=I+1;
        StringGrid1.RowCount:=StringGrid1.RowCount+1;
      end;
      

  4.   

    StringGrid1.Rowcount:=StringGrid1.Rowcount+1