我正在嘗試製作一個按鈕,用於點擊時設置另一個按鈕的文本。但是當我這樣做時,需要第二次點擊才能完成第二個操作,即設置按鈕文本。按鈕需要兩個單獨的點擊才能完成操作
private void button2_Click(object sender, EventArgs e)
{
// Button has been clicked.
if(a == 1){
// The button has been clicked only once
button2.Text = "Repeat: Off";
button6.Text = "Shuffle: Off";
loop = false;
shuffle = false;
a = 2;
} else if(a == 2) {
// The button has been clicked only twice :c
button2.Text = "Repeat: On";
button6.Text = "Shuffle: Off";
loop = true;
shuffle = false;
a = 1;
}
}
我不知道這是怎麼發生的。
你設置一個斷點,並通過你的方法步驟,一邊看你的變量值怎麼改? –
可能重複http://stackoverflow.com/questions/13486245/winforms-how-to-call-a-double-click-event-on-a-button –
你是否初始化A!= 0? – TaW