怎么获得焦点?(10分)

  • 主题发起人 sohuandsina
  • 开始时间
S

sohuandsina

Unregistered / Unconfirmed
GUEST, unregistred user!
我在edit1里输入按回车后,会自动跳到edit2里面等待输入。
begin
.........
end;
 
设置好tableorder 然后
onkeyup
case Key of
VK_Return://响应回车键。
begin
if not (ActiveControl is TDBGrid) and not (ActiveControl is TMemo) then
begin
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;
 
在edit1的KeyDown事件中写
if (Key = VK_Down)) then
Key=VK_TAB
 
edit1.setfocus;
EDIT就获得了焦点。
 
begin
if (Key = VK_return) then
edit2.SetFocus;
end;
 
前面四位讲得都不错啊,呵呵!一个一个的都好热心哦!
 
在EDIT1的ONKEYPRASS写
if (key = #13) then
edit2.setfocus;
 
procedure TForm1.EDIT1KeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
if Key = VK_Return then
keybd_event( VK_TAB, MapVirtualKey( VK_TAB, 0 ), 0 , 0 );
end;
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
766
DelphiTeacher的专栏
D
D
回复
0
查看
708
DelphiTeacher的专栏
D
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
顶部