1
這是我創建按鈕和附加事件給他們的代碼。單擊事件處理程序的一組按鈕與額外的參數
for (int i = 0; i < NumberOfQuestion; i++)
{
Telerik.WinControls.UI.RadButton button = new Telerik.WinControls.UI.RadButton();
// radButton1
//
button.Anchor = AnchorStyles.None;
button.Font = new Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold);
button.Location = new Point(65 * i + 15, 10);
button.Name = "btn_cauhoi" + (i + 1);
button.Size = new Size(60, 35);
button.TabIndex = 1 + i;
button.Text = "Câu " + (i + 1);
button.Click += (sender, e) => Button_Click(sender, e, (i + 1));
//
panel_nut_cauhoi.Controls.Add(button);
}
private void Button_Click(object sender, EventArgs e, int questionIndex)
{
MessageBox.Show(questionIndex.ToString());
}
它只顯示questionIndex =的lastIndex的+ 1當我點擊每個按鈕
有人幫助我,好嗎!
選項1不工作 –
檢查編輯。糾正。 –
我又遇到了一個問題。你能幫我嗎 ? http://stackoverflow.com/questions/41311043/button-trigger-event-gotfocus-repeattly –