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 –