C# 有一个问题。我已经单击了第二个文本框,但它一直出现在两个文本框中。我希望当我点击它的文本框时,这个数字会弹出。1当时
我的代码: 名称空间文本框 { 公共部分类Form1:Form { 公共表格1() { 初始化组件(); }C# 有一个问题。我已经单击了第二个文本框,但它一直出现在两个文本框中。我希望当我点击它的文本框时,这个数字会弹出。1当时,c#,C#,我的代码: 名称空间文本框 { 公共部分类Form1:Form { 公共表格1() { 初始化组件(); } private void button2_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "2"; } private void button1_Click(object sender, EventArgs e) { t
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "2";
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox2.Text += "1";
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
}
}在您的
按钮1u单击
方法中,textBox1.Text
归因于将“1”连接到textBox2.Text
的结果。我认为这就是问题的原因
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "2";
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox2.Text += "1";
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
}