在Grid1KeyPress事件中添加以下代码:
begin
if Key=#13 then
if not(ActiveControl is TwwDBGrid) then
begin
Key:=#0;
Perform(WM_NEXTDLGCTL,0,0);
end else
if (ActiveControl is TwwDBGrid) then with TwwDBGrid(ActiveControl) do
if SelectedIndex < 某一字段的索引号即第几列 then selectedindex:=selectedindex+1 else
begin
(Sender as TwwDBGrid).DataSource.DataSet.Next;
selectedindex:=0; //应增加此句,否则焦点无法到第一个字段
if (Sender as TwwDBGrid).DataSource.DataSet.Eof then
(Sender as TwwDBGrid).DataSource.DataSet.Append;
selectedindex:=0;
end;
end;