CheckedListBox
以下からプログラムで作成したコントロールがあります...
Button btnSelectAll = new Button();
btnSelectAll.Text = "Select All";
btnSelectAll.Name = item.Id;
btnSelectAll.Tag = param.Id;
CheckedListBox chkListBox = new CheckedListBox();
chkListBox.Size = new System.Drawing.Size(flowPanel.Size.Width - lblListBox.Size.Width - 10, 100);
//set the name and tag for downstream event handling since two-way bindings are not possible with control
chkListBox.Tag = param.Id;
chkListBox.Name = item.Id;
chkListBox.ItemCheck += new ItemCheckEventHandler(chkListBox_ItemCheck);
btnSelectAll.Click += new EventHandler(btnSelectAll_Click);
項目を動的に作成したときに、chkListBox の ItemCheck がヒットするたびにイベント ハンドラーも追加したことに注意してください。コードのどこかで...私は...
CheckedListBox tmpCheckedListBox = cntrl as CheckedListBox;
for (int i = 0; i < tmpCheckedListBox.Items.Count; i++)
{
tmpCheckedListBox.SetItemChecked(i, true);
}
上記を実行すると、ItemChecked イベントが発生しません。ユーザーがアイテムをクリックしたかのように、このイベントを発生させるにはどうすればよいですか?