| « | February 2026 | » | | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | |
| 公告 |
| 暂无公告... |
| Blog信息 |
|
blog名称:赤字先生 日志总数:28 评论数量:67 留言数量:0 访问次数:133643 建立时间:2006年10月8日 |

| |
|
[软件技术]C#实现用Enter键和Tab键同样功能 软件技术
赤字先生 发表于 2006/10/8 17:39:06 |
| 在Form_Load中输入如下代码:
foreach(Control ctrl in this.Controls) { if ((ctrl is TextBox) || (ctrl is ComboBox)) //如果文本框或下拉框放在组合框中,你应该用如groupBox1.TextBox { ctrl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.EnterKeyDown); } }然后在EnterKeyDown事件中定义当按下的键为Enter键时,发送Tab键,程序如下:
private void EnterKeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if(e.KeyCode==Keys.Enter) { System.Windows.Forms.SendKeys.Send("{TAB}"); } } |
|
|