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 –