菜鸟求解答C#两个textbox之间获取焦点 新手学C#问下 两个textbox控件(txtbox1,txtbox2) txtbox1用条码扫描枪来扫描一个数字切换到txtbox2 验证后焦点再返回txtbox1 怎么写 ,希望各位大神们帮帮忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 额 我的意思是从txtbox1 相当于回车下 到txtbox2 再回车下返回到txtbox这个过程怎么写 private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (char)13) { textBox2.Focus(); } t1按回车焦点到t2 txtbox1.Focus();private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar==(char)13) { txtbox1.Focus();} } 或设置this.ActiveControl 4楼正解 其实还有一种方法 重写protected override void OnKeyPress(KeyPressEventArgs e)这个方法 具体里边怎么写一时不记得了 Form1_Load里设置this.KeyPreview = true; private void Form1_KeyDown(object sender, KeyEventArgs e){if (e.KeyCode == Keys.Enter && textBox1.Focused == true){textBox2.Focused == true}if (e.KeyCode == Keys.Enter && textBox2.Focused == true){textBox1.Focused == true}} private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (char)13) { textBox2.Focus(); }private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (char)13) { textBox3.Focus(); }//以此类推即可 C#新手提问? Socket非法退出 把C++程序改写为C#中遇到的问题 关于TabControl的事件问题? 登陆时,输入用户名和密码后,按回车后触发登陆按钮,直接登陆? 求大神!winform安装界面美化怎么美化? WPF,可不可以在用户控件库中创建自定义控件? 高手请进【关于gridview更新的问题】 如何制作c#程序升级包 打包程序只能安装一次 在此安装提示先卸载以前版本 再安装还有如何把sql数据库也打包进去 错误“不可访问“Wrox.Samples.MyRemoteObject”,因为它受保护级别限制”是为什么? 几个菜鸟问题 pictureBox做视频预览的一个问题!求解答!
{
if (e.KeyChar == (char)13)
{
textBox2.Focus();
}
t1按回车焦点到t2
private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar==(char)13)
{
txtbox1.Focus();
}
}
或设置this.ActiveControl
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter && textBox1.Focused == true)
{
textBox2.Focused == true
}
if (e.KeyCode == Keys.Enter && textBox2.Focused == true)
{
textBox1.Focused == true
}
}
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
textBox2.Focus();
}
private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
textBox3.Focus();
}
//以此类推即可