想在dbgril中增加一个计数列,怎么办(数据库,和列属性怎么改),急!!!!!

解决方案 »

  1.   

    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin
    with DBGrid1.DataSource.DataSet do
    begin
     if DataCol = 0 then//第一列
       DBGrid1.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, IntToStr(RecNo));
    end;
      

  2.   

    双机使用的Table或 Query 在出现的对话框里添加一个计算字段
      

  3.   

    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin 
      if column.FieldName='No' then  
      begin
           Dbgrid1.Canvas.Pen.Color:=clblack;
           Dbgrid1.Canvas.TextOut(rect.left,rect.top,inttostr  (DBGrid1.DataSource.DataSet.RecNo));
      end;    
    end;
      

  4.   

    只要数据库添加或删除记录~~
    DBGrid就会相应的增加或删除一行~~DBGrid只不过是将数据库的记录以表格的形式显示出来~~
    所以对想DBGrid进行操作就必须对数据库进行操作~~
      

  5.   

    看一下这个,我没法结贴,有人进我就结
    http://community.csdn.net/Expert/topic/3329/3329927.xml?temp=.3667719