using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;namespace Ques_1 { public partial class Form1 : Form { private const int textSize = 5;//设置你每个textbox输入上限 public Form1() { InitializeComponent(); } //这样写不能保证像激活码那样在第一个复制进去全部刚好,要一个个的textbox输入,要是要那种的话,可以采用下面的另一种方式 private void Form1_Load(object sender, EventArgs e) { this.textBox1.MaxLength = textSize; this.textBox2.MaxLength = textSize; this.textBox3.MaxLength = textSize; this.textBox4.MaxLength = textSize; this.textBox1.TextChanged += new EventHandler(textBox1_TextChanged); this.textBox2.TextChanged += new EventHandler(textBox2_TextChanged); this.textBox3.TextChanged += new EventHandler(textBox3_TextChanged); this.textBox4.TextChanged += new EventHandler(textBox4_TextChanged); } void textBox4_TextChanged(object sender, EventArgs e) {
public void TextBoxAll_TextChanged(object sender,EventArgs e)
{
if((sender as TextBox).Text.Length > 5)//看你自己指定多少个了
{
SendKeys.Send("{TAB}");
}
}没开vs,如果代码敲错你对照大小写啥的改改。
{
textBox1.MaxLength = textBox2.MaxLength = textBox3.MaxLength = textBox4.MaxLength = 10;
textBox1.TextChanged += new EventHandler(OnTextChanged);
textBox2.TextChanged += new EventHandler(OnTextChanged);
textBox3.TextChanged += new EventHandler(OnTextChanged);
textBox4.TextChanged += new EventHandler(OnTextChanged);
} private void OnTextChanged(object sender, EventArgs e)
{
if ((sender as TextBox).Text.Length >= (sender as TextBox).MaxLength)
{
SendKeys.Send("{TAB}");
}
}
{
TextBox txt=sender as TextBox;
if (txt.Text.Length >= 6)
{
this.Controls[""].Focus();
}
}
this.ActiveControl = textBox2;
SendKeys.Send("{TAB}");
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Ques_1
{
public partial class Form1 : Form
{
private const int textSize = 5;//设置你每个textbox输入上限
public Form1()
{
InitializeComponent();
}
//这样写不能保证像激活码那样在第一个复制进去全部刚好,要一个个的textbox输入,要是要那种的话,可以采用下面的另一种方式
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.MaxLength = textSize;
this.textBox2.MaxLength = textSize;
this.textBox3.MaxLength = textSize;
this.textBox4.MaxLength = textSize;
this.textBox1.TextChanged += new EventHandler(textBox1_TextChanged);
this.textBox2.TextChanged += new EventHandler(textBox2_TextChanged);
this.textBox3.TextChanged += new EventHandler(textBox3_TextChanged);
this.textBox4.TextChanged += new EventHandler(textBox4_TextChanged);
} void textBox4_TextChanged(object sender, EventArgs e)
{
} void textBox3_TextChanged(object sender, EventArgs e)
{
if (textBox3.Text.Length >= textSize)
{
this.textBox4.Focus();
}
} void textBox2_TextChanged(object sender, EventArgs e)
{ if (textBox2.Text.Length >= textSize)
{
this.textBox3.Focus();
}
} void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text.Length >= textSize)
{
this.textBox2.Focus();
}
}
}
}