您当前的位置:首页 > 建站知识 > 编程知识

在TDBGrid中将Enter键用作Tab键

发布时间: 2013-08-17 │ 浏览:3000 

在TDBGrid中将Enter键用作Tab键

//设置窗体的KeyPreview为True

procedure TForm1.FormKeyPress(Sender: Tobject; var Key: Char);

begin
if Key = #13 then
if not (ActiveControl is TDBGrid) then
begin
Key := #0;
Perform(WM_NEXTDLGCTL, 0, 0);
end

else
if (ActiveControl is TDBGrid) then
with TDBGrid(ActiveControl) do
if selectedindex < (fieldcount -1) then
selectedindex := selectedindex +1
else
selectedindex := 0;

end;