if key=#13 then <br> begin //按下回车键<br> if DBGrid1.SelectedIndex <> DBGrid1.Columns.Count - 1 then //如果不在最后一列则移到下一列<br> DBGrid1.SelectedIndex := DBGrid1.SelectedIndex + 1<br> else<br> begin //在最后一列,则移到下一条记录<br> DBGrid1.DataSource.DataSet.Next;<br> DBGrid1.SelectedIndex := 0;<br> end;<br> Key := #0; //屏蔽所输入的回车键,使DBGrid处于浏览状态;如无此行代码,则DBGrid将处于编辑状态<br> end;<br>end;