【发布时间】:2014-06-22 17:23:35
【问题描述】:
我得到了一个包含 5 个组合框的数组。我想为整个数组的“SelectionChangeCommitted”事件创建一个 void,它可以确定从哪个组合框调用 void。这是包含 5 个空格的当前代码。每个组合框一个。
private ComboBox[] statsValues;
public frmMain()
{
InitializeComponent();
statsValues = new ComboBox[5];
for (byte b = 0; b < statsValues.Length; b++)
{
statsValues[b] = new ComboBox();
statsValues[b].Location = new System.Drawing.Point(69, 193 + 30 * b);
statsValues[b].DropDownStyle = ComboBoxStyle.DropDownList;
}
Controls.AddRange(statsValues);
statsValues[0].SelectionChangeCommitted += new System.EventHandler(cmbSTR_SelectionChangeCommitted);
statsValues[1].SelectionChangeCommitted += new System.EventHandler(cmbDEX_SelectionChangeCommitted);
statsValues[2].SelectionChangeCommitted += new System.EventHandler(cmbCON_SelectionChangeCommitted);
statsValues[3].SelectionChangeCommitted += new System.EventHandler(cmbINT_SelectionChangeCommitted);
statsValues[4].SelectionChangeCommitted += new System.EventHandler(cmbWIS_SelectionChangeCommitted);
}
private void cmbSTR_SelectionChangeCommitted(object sender, EventArgs e)
{
//Code...
}
private void cmbDEX_SelectionChangeCommitted(object sender, EventArgs e)
{
//Code...
}
private void cmbCON_SelectionChangeCommitted(object sender, EventArgs e)
{
//Code...
}
private void cmbINT_SelectionChangeCommitted(object sender, EventArgs e)
{
//Code...
}
private void cmbWIS_SelectionChangeCommitted(object sender, EventArgs e)
{
//Code...
}
我想为它们创建一个单独的 void,它可以确定从哪个组合框调用它。
【问题讨论】:
-
我想为事件创建一个空虚......它可以确定从哪个组合框调用空虚 ??
-
我认为你的意思是写“事件处理程序”而不是 void/emptiness。
-
我疯了 xD 而且是的,哈哈。
标签: c# arrays combobox void eventhandler