以下是回車代替TAB鍵但是我卻不會代替,請幫我看一下.(我在D6運行):
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
begin
with tdbgrid(activecontrol) do
if selectedindex < (fieldcount-1) then
selectedindex:=selectedindex+1
else selectedindex:=0;
end;end;
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
begin
with tdbgrid(activecontrol) do
if selectedindex < (fieldcount-1) then
selectedindex:=selectedindex+1
else selectedindex:=0;
end;end;
begin
selectNext(activeControl,true,true);
Key := #0;
end;