我想让查询值在TDBGRID中的第一列显示对数据行的排列顺序号,例如:序号  F1  F2   F3
1
2
3
4

解决方案 »

  1.   

    如果是oracle数据库,引用rownum就可以了
      

  2.   

    序号的自动生成
    1.定义变量
      private 
            maxno:integer;
      public
            bmodified:boolean;
    2.写函数
      function max(const a,b:integer):integer;
      begin
        if a>b then
           result:=a
        else
           result:=b;
      end;
    3 FormCreate 中加入
      bmodified:=false;
      while not adoq_rsinfo.eof do
      begin
         maxno:=max(maxno, adoq_rsinfo.fields[0].asinteger);
         adoq_rsinfo.next;
      end;
    4。在你的添加按钮中加入
      adoq_rsinfo.field[0].asinteger:=maxno+1;