C# 为活动创建一个空白“;SelectionChangeCommitted";对于组合框数组
我得到了一个包含5个组合框的数组。我想为整个数组的事件“SelectionChangeCommitted”创建一个void,它可以确定从哪个组合框调用void。以下是当前代码,其中包含5个空格。每个组合框对应一个C# 为活动创建一个空白“;SelectionChangeCommitted";对于组合框数组,c#,arrays,combobox,void,eventhandler,C#,Arrays,Combobox,Void,Eventhandler,我得到了一个包含5个组合框的数组。我想为整个数组的事件“SelectionChangeCommitted”创建一个void,它可以确定从哪个组合框调用void。以下是当前代码,其中包含5个空格。每个组合框对应一个 private ComboBox[] statsValues; public frmMain() { InitializeComponent(); statsValues = new ComboBox[5]; for (byte
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...
}
private组合框[]statsValues;
公共财政收入()
{
初始化组件();
statsValues=新组合框[5];
for(字节b=0;b
我想为它们创建一个单独的void,它可以确定从哪个组合框调用它。假设“void”表示“eventhandling方法”
private void cmbALL_SelectionChangeCommitted(object sender, EventArgs e)
{
ComboBox thisOne = (ComboBox)sender;
//Code...
}
我想为这个活动创造一个空白。。。它可以确定从哪个组合框调用空值??我想你是想编写“事件处理程序”而不是void/empty。我喜欢疯狂的xD和yes of c lol。所以将所有组合框绑定到同一个void?
statsValues[x]。SelectionChangeCommitted+=cmbALL\u SelectionChangeCommitted代码>是它与检查发送者(组合框)是否等于其中一个组合框的if语句完美配合!我还可以在for循环中包含事件处理程序;)Thx伙计们:D