本站首页    管理页面    写新日志    退出


«may 2026»
12
3456789
10111213141516
17181920212223
24252627282930
31


公告
================

注会练习软件
http://www.cpasoft.com.cn
我的注会软件官网

http://blog.163.com/abc7105@126/

 

 


哈哈,热爱快“过气”的DELPHI


我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:注册会计师(注会)练习软件
日志总数:398
评论数量:116
留言数量:27
访问次数:3305822
建立时间:2005年6月6日




How to make the Enter key work like Tab in tdbgrid(delphi 5-7)
软件技术

吕向阳 发表于 2006/10/6 8:55:04

How to make the Enter key work like Tab From Zarko Gajic,Your Guide to Delphi Programming.FREE Newsletter. Sign Up Now! Enter-ing Tab We know that, generally, pressing the Tab key moves the input focus to next control and Shift-Tab to previous in the tab order of the form. When working with Windows applications, most users intuitively expect the Enter key to behave like a Tab key. Over the past few years, I've seen a lot of third-party code for implementing better data entry processing in Delphi. In this article, I'll try to bring you the best methods I have found (with some modifications of my own). Examples below are written with the assumption that there is no default button on the form. When your form contains a button whose Default property is set to True, pressing Enter at runtime executes any code contained in the button's OnClick event handler. Enter as TabThe next code causes Enter to behave like Tab, and Shift+Enter like Shift+Tab: ~~~~~~~~~~~~~~~~~~~~~~~~~procedure TForm1.Edit1KeyPress (Sender: TObject; var Key: Char) ;begin   If Key = #13 Then Begin    If HiWord(GetKeyState(VK_SHIFT)) <> 0 then     SelectNext(Sender as TWinControl,False,True)    else     SelectNext(Sender as TWinControl,True,True) ;     Key := #0   end;end;~~~~~~~~~~~~~~~~~~~~~~~~~ in DBGridIf you want to have similar Enter (Shift+Enter) processing in DBGrid: ~~~~~~~~~~~~~~~~~~~~~~~~~procedure TForm1.DBGrid1KeyPress (Sender: TObject; var Key: Char) ;begin   If Key = #13 Then Begin    If HiWord(GetKeyState(VK_SHIFT)) <> 0 then begin     with (Sender as TDBGrid) do     if selectedindex > 0 then      selectedindex := selectedindex - 1     else begin      DataSource.DataSet.Prior;      selectedindex := fieldcount - 1;     end;    end else begin     with (Sender as TDBGrid) do     if selectedindex < (fieldcount - 1) then      selectedindex := selectedindex + 1     else begin      DataSource.DataSet.Next;      selectedindex := 0;     end;   end;   Key := #0   end;end;


阅读全文(1594) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.641 second(s), page refreshed 144819847 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号