C#textbox控件数组中按回车移动焦点(初学) 动态地中窗体中添加一个TEXTBOX控件数组。如何按回车让焦点在TEXTBOX控件数组中移动 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void Form1_Load(object sender, System.EventArgs e){ TextBox []txt = new TextBox[10]; for(int i=0;i<10;i++) { txt[i]= new TextBox(); txt[i].Location = new System.Drawing.Point(8, 10+i*30); txt[i].Size = new System.Drawing.Size(50, 21); txt[i].TabIndex = i; txt[i].KeyPress+=new KeyPressEventHandler(txt_KeyPress); this.Controls.Add(txt[i]); }}private void txt_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e){if(e.KeyChar==13){ SendKeys.Send("{TAB}");}} 和1楼的方法差不多,参考如下代码:protected override bool ProcessDialogKey(Keys keyData){ if ((ActiveControl is TextBox || ActiveControl is ComboBox) && keyData == Keys.Enter) { keyData = Keys.Tab; } return base.ProcessDialogKey(keyData);} 为什么我的已安装模板里没有数据集? 传进来一个动物,如果它是猫就return new 猫();是狗就return new 狗(); windows程序如何制作象网页框架一样的效果 知道了窗口句柄,如何操作这个窗口中的控件,比如TextBox 关于treeview的几个问题???? 存款计算器没着落..有请各位高手指点.. 怎样实现工具栏总在窗口的顶部 连接数据库失败为什么? 哪位大哥告诉我几个 优秀得C#论坛,100分 在C#中怎么得到汉字的拼音码? 8个字节的数组,怎么把高4位和低4位互换一下 求字符串最佳分解方法
private void Form1_Load(object sender, System.EventArgs e)
{
TextBox []txt = new TextBox[10];
for(int i=0;i<10;i++)
{
txt[i]= new TextBox();
txt[i].Location = new System.Drawing.Point(8, 10+i*30);
txt[i].Size = new System.Drawing.Size(50, 21);
txt[i].TabIndex = i;
txt[i].KeyPress+=new KeyPressEventHandler(txt_KeyPress);
this.Controls.Add(txt[i]);
}
}
private void txt_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar==13)
{
SendKeys.Send("{TAB}");
}
}
protected override bool ProcessDialogKey(Keys keyData)
{
if ((ActiveControl is TextBox || ActiveControl is ComboBox) &&
keyData == Keys.Enter)
{
keyData = Keys.Tab;
}
return base.ProcessDialogKey(keyData);
}