なぜこのエラーが発生するのか混乱しています:
Combobox
アイテム:
private readonly string[] cbTexts = new string[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "(Cleare)" };
動的comboboxes
:
private void comboOptions()
{
cmb = new ComboBox[countWaiters];
int width = 100;
int height = 20;
for (int i = 0; i <= 3; ++i)
{
newBox = new ComboBox();
newBox.Text = "(Request)";
newBox.Size = new Size(width, height);
newBox.Location = new Point(0, (i * height));
cmb[i] = newBox;
cmb[i].SelectedIndexChanged += new EventHandler(cmb_SelectedIndexChanged);
foreach (string cbText in cbTexts)
{
cmb[i].Items.Add(cbText);
}
pnlRequests.Controls.Add(newBox);
}
}
SelectedIndexChanged
のイベントcomboboxes
:
void cmb_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox senderCmb = (ComboBox)sender;
int row = (int)senderCmb.Tag;
//this is where the program crashes
//more code located here that does something
}
エラー: 注: 一部のメソッド名はこの画像から変更されていますが、何も影響しません