对我收到此错误的原因感到困惑:
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
}
错误:注意:此图像中的某些方法名称已更改,但没有任何影响