第一行的表头已经设好 ,通过ADOQuery查询出的N行,如何将数据从第二行开始放到StringGrid?,,谢谢. Grids.Cells[1,0]:='订单号';
 Grids.Cells[2,0]:='款号';
 Grids.Cells[3,0]:='颜色';
 Grids.Cells[4,0]:='尺码';
 Grids.Cells[5,0]:='数量';
 Grids.Cells[6,0]:='单位';
 Grids.Cells[7,0]:='原因';
 Grids.Cells[8,0]:='处理结果';

解决方案 »

  1.   

    试了很多次不行.         ADOQuery1.Close;
             ADOQuery1.SQL.Clear;
             ADOQuery1.SQL.Add('省略......');
             ADOQuery1.Open;
             ADOQuery1.First;
             Grids.RowCount:=ADOQuery1.RecordCount; 
             while not ADOQuery1.Eof do
             begin
             for i:=1 to Grids.RowCount do
                    begin
                    Grids.Cells[1,j]:=ADOQuery1.fieldbyName('生产订单号').AsString;
                    Grids.Cells[2,j]:=ADOQuery1.fieldbyName('款号').AsString;
                    Grids.Cells[3,j]:=ADOQuery1.fieldbyName('颜色').AsString;
                    Grids.Cells[4,j]:=ADOQuery1.fieldbyName('尺码').AsString;
                    Grids.Cells[5,j]:=ADOQuery1.fieldbyName('数量').AsString;
                    Grids.Cells[6,j]:=ADOQuery1.fieldbyName('单位').AsString;
                    Grids.Cells[7,j]:=ADOQuery1.fieldbyName('原因').AsString;
                    Grids.Cells[8,j]:=ADOQuery1.fieldbyName('处理结果').AsString;
                    end
                    end;
                    ADOQuery1.next;
                    j:=j+1;
                  end;
      

  2.   

    用StringGrid,不但写入的速度慢,而且操作也很不方便!为什么不要DBGridEh呢,或是delphi7自带的DBgrid,这样同Adoquery同步操作,很方便啊!
      

  3.   

      把代码改了一下,可以在stringgrid中正确显示第一条记录了,ADOQuery3查出来有两条, 第一条是正确的,第二条是错误的,因为内容和第一条一样,是不是ADOQuery3.next没有起作用?                     ADOQuery3.Close;
                      ADOQuery3.SQL.Clear;
                      ADOQuery3.SQL.Add('省略......');
                      ADOQuery3.Open;
                      ADOQuery3.First;
                      Grids.RowCount:=ADOQuery3.RecordCount;
                      while not ADOQuery3.Eof do
                      begin
                      for i:=1 to Grids.RowCount do
                      begin
                      Grids.Cells[1,i]:=ADOQuery1.fieldbyName('生产订单号').AsString;
                      Grids.Cells[2,i]:=ADOQuery1.fieldbyName('款号').AsString;
                      Grids.Cells[3,i]:=ADOQuery1.fieldbyName('颜色').AsString;
                      Grids.Cells[4,i]:=ADOQuery1.fieldbyName('尺码').AsString;
                      Grids.Cells[5,i]:=ADOQuery1.fieldbyName('数量').AsString;
                      Grids.Cells[6,i]:=ADOQuery1.fieldbyName('单位').AsString;
                      Grids.Cells[7,i]:=ADOQuery1.fieldbyName('原因').AsString;
                      Grids.Cells[8,i]:=ADOQuery1.fieldbyName('处理结果').AsString;
                      ADOQuery3.next;
                    end;
                  end;
               end;
             end
        end
    end;end.
      

  4.   

    DBGrid挺方便,因为涉及到后面还有很多操作,stringgrid灵活性好点.
      

  5.   

    ADOQuery1 没有改成ADOQuery3.头晕了
      

  6.   

    是的,完全接受.又有一个问题,数据在stringgrid中显示后只是一行,要用点一之后才会显示其它行.好像没有即时刷新.
      

  7.   

    最后加
        stringgrid1.Refresh;//手动重刷画布