菜鸟求解答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#调MFC dll的测试程序,返回值不对,大侠帮忙解决下 请教 如何反射非公共的函数? dataGridView中数据改动问题 C#中怎样设置文本框的属性,当按一下Tab键以后自动转到下一文本框(焦点从txtA二转到txtB中去) Graphics实例化的问题 关于socket的问题 新手请教正则问题 如何使用C# 开发XP风格的WinForm呀! 几个菜鸟问题 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();
}
//以此类推即可