请教高手(现在没有分,有了以后献上)
有两个textbox控件:文本框textbox1和文本框textbox2,textbox1里输入完成离开时textbox2(只读)自动显示从textbox1中截取的前4个字符,代码怎样写?(现在没有分,有了以后献上)
2009-10-08 09:53
2009-10-08 11:09
2009-10-08 16:07
程序代码: private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.ToString() == Keys.Enter.ToString())
{
if (this.textBox1.Text.Length >= 4)
{
this.textBox2.Text = this.textBox1.Text.Substring(0, 4);
}
else
{
this.textBox2.Text = this.textBox1.Text;
}
}
}
程序代码: private void textBox1_Leave(object sender, EventArgs e)
{
if (this.textBox1.Text.Length >= 4)
{
this.textBox2.Text = this.textBox1.Text.Substring(0, 4);
}
else
{
this.textBox2.Text = this.textBox1.Text;
}
}

2009-10-08 20:34
2009-10-08 21:36
2009-10-09 21:35
2009-10-09 22:47