我想在dbgrid加一列显示数据的序号,按材料输了一下内容
双击DBGrid,先把所有字段加进去,再在最前面加一个字段,在DrawColumnCell中写  
procedure  TForm1.DBGrid1DrawColumnCell(Sender:  TObject;  const  Rect:  TRect;  
   DataCol:  Integer;  Column:  TColumn;  State:  TGridDrawState);  
begin  
   if  Column.Index  =  0  then  
   with  DBGrid1.Canvas  do  begin  
       FillRect(Rect);  
       TextOut(Rect.Left+2,  Rect.Top+2,  IntToStr(DBGrid1.DataSource.DataSet.RecNo));  
   end;  
end;  
运行报错,有DBGrid1DrawColumnCell未曾定义等等
麻烦各位看看那里不对,急