【发布时间】:2018-03-07 20:47:49
【问题描述】:
我有几个按钮和一个文本框。我想这样做,当我按下按钮 1 时,文本框中的文本转到按钮,当我按下按钮 2 时,文本转到按钮 2,依此类推。我现在有这个:
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Text = TextBox1.Text;
}
protected void Button2_Click(object sender, EventArgs e)
{
Button2.Text = TextBox1.Text;
}
protected void Button3_Click(object sender, EventArgs e)
{
Button3.Text = TextBox1.Text;
}
编辑:有更短的方法吗?
【问题讨论】:
-
((Button)sender).Text = TextBox1.Text; -
你需要按下按钮吗?
-
是的,当我单击按钮时,我希望文本框中的文本继续显示在按钮上。
-
那么@EdPlunkett 的评论就是你的解决方案