码迷,mamicode.com
首页 > Windows程序 > 详细

Winfrom 文本框回车进入下一个个单元格(TextBox)

时间:2016-07-20 10:21:57      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:

1、重写方法 OnShown

 1 protected override void OnShown(EventArgs e)
 2 {
 3     base.OnShown(e);
 4     foreach (Control ct in this.Controls)
 5     {
 6         TextBox tx = ct as TextBox;
 7         if (tx != null)
 8         {
 9             tx.KeyDown += (sender, e_args) =>
10             {
11                 if (e_args.KeyCode == Keys.Enter)
12                 { this.SelectNextControl(tx, true, true, false, true); }
13             };
14 
15         }
16     }
17 }

 

2、修改TextBox的TabIndex属性

1 this.txt_id.TabIndex = 1
2 this.txt_name.TabIndex = 2;
3 ……

 

Winfrom 文本框回车进入下一个个单元格(TextBox)

标签:

原文地址:http://www.cnblogs.com/cbread/p/5687221.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!