ListBox TextBox各一个
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (textBox1.Text.Trim().Length == 5)
{
this.textBox1.Focus();
this.listBox1.Items.Add(textBox1.Text.Trim());//添加到ListBox
}
else if (textBox1.Text.Trim().Length > 5)
{
this.textBox1.Clear();
}
}
private void Form1_Activated(object sender, EventArgs e)
{
textBox1.Focus();
}