在delphi中按下enter键,使它相当按了Tab键,如何实现?

cm 2003-07-02 09:47:42
在delphi中按下enter键,使它相当按了Tab键,如何实现?
有各键的代码吗
...全文
363 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
luopan0021 2004-03-02
  • 打赏
  • 举报
回复
好主意
knife_s 2004-03-02
  • 打赏
  • 举报
回复
小技巧
radeonle 2003-07-03
  • 打赏
  • 举报
回复
if Key = #13 then
key := #10;
shenjhshen 2003-07-03
  • 打赏
  • 举报
回复
用Enter键代替Tab键



在实际的程序开发中我们经常有这样的要求,用户不喜欢用Tab键,他希望用Enter键来代替。我们应该什么做呢?

首先:设定Form的KeyPreview属性为True。

其次:把Form上的所有Button的Default属性设为False。

最后:在Form的OnKeyPress事件中添加如下代码:

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

if Key = #13 then

begin

Key := #0;

Perform(Wm_NextDlgCtl,0,0);

end;

end;

把DBCombobox的taborder属性设置为你要次系,没有错的

ronaldli 2003-07-03
  • 打赏
  • 举报
回复
KeyPreview := True
而且上面的代码写在Form的OnKeyPress中
exhx 2003-07-03
  • 打赏
  • 举报
回复
http://bbs.2ccc.com/topic.asp?topicid=19391

看这个哦,马上解决
yangchuzi 2003-07-03
  • 打赏
  • 举报
回复
gz
李_军 2003-07-02
  • 打赏
  • 举报
回复
if Key=#13 then
if not(AForm.ActiveControl is TDbGrid) then
begin //不是在TDbgrid控件内
//key := #0;
AForm.PerForm(WM_NEXTDLGCTL,0,0); //移到下一个控件
end
else if (AForm.ActiveControl is TDBGrid) then
begin //是在TDbgrid控件内
with TDbgrid(AForm.ActiveControl) do
if Selectedindex<(Fieldcount-1) then
Selectedindex := Selectedindex+1
else
Selectedindex := 0;
end;
chenshu19791003 2003-07-02
  • 打赏
  • 举报
回复
if Key = VK_RETURN then
Perform(WM_NEXTDLGCTL, 0, 0);

keydown事件
things 2003-07-02
  • 打赏
  • 举报
回复
if Key = #13 then
SendMessage(Handle,WM_KeyDown,VK_TAB,0) ;
things 2003-07-02
  • 打赏
  • 举报
回复
if Key = #13 then
SelectNext(ActiveControl, True, True);

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧