回车键怎样代替Tab键(50分)

  • 主题发起人 主题发起人 dgguo
  • 开始时间 开始时间
D

dgguo

Unregistered / Unconfirmed
GUEST, unregistred user!
在一个DBGRID中用回车键怎样代替Tab键焦点,可以轻松实现,如果把一个字段较多的表,用两个Dbgrid控件显示,则敲回车键只在第一个Dbgrid中来回移动,而不能移动到第二个Dbgrid空间中去,望各位高手指教
 
在你需要转移的位置(比如某列)写代码
转移焦点到第二个DBGRID就可以了啊
 
procedure MyFormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
with sender as TForm do
if (ActiveControl is TDbGrid) then
begin
with TDbGrid(ActiveControl) do
begin
if SelectedIndex<(Fieldcount-1) then
SelectedIndex:=SelectedIndex+1
else
SelectedIndex:=0;
{endif}
end; {with}
end
else
if not (ActiveControl is TBitBtn) then
begin
Key := #0; { clear enter key }
Perform(WM_NEXTDLGCTL, 0, 0); { move to next control }
end;{if}
{endif}
{endif}
end;
 
多人接受答案了。
 
后退
顶部