4
我有幾個按鈕和一個文本框。我想這樣做,當我按下按鈕1時,文本框中的文本將轉到按鈕,而當我按下按鈕2時,文本將轉到按鈕2,等等。我現在有這樣的:C#如何設置不同按鈕的按鈕文本到同一個文本框
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;' –
你需要按下按鈕嗎? –
是的,當我點擊一個按鈕時,我想讓文本框中的文本進入按鈕。 – Aiko