组合框值取决于其他组合框值

时间:2019-06-16 08:47:26

标签: c# combobox

使用视觉C#,我有5个组合框。我希望所有人的数字都为1-5,但是选择一个后,其他所有数字都消失了。即如果我从组合框1中选择数字3,则其他任何人都没有数字3。我会发布代码,但是对此非常有想法。预先感谢

2 个答案:

答案 0 :(得分:0)

您可以通过编程方式在父ComboBox上添加ComboBox,例如:

    private void ComboBoxParent_SelectedIndexChanged(object sender, EventArgs e)
    {
        int numComboBoxes = 5;

        for (int i = 0; i < numComboBoxes; i++)
        {
            ComboBox comboBoxChild = new System.Windows.Forms.ComboBox();
            comboBoxChild.Location = new System.Drawing.Point(0, 21 * i);//Position on the Form
            comboBoxChild.Size = new System.Drawing.Size(121, 21);//Size of the ComboBox

            this.Controls.Add(comboBoxChild);
        }
    }

答案 1 :(得分:-1)

  *  The dispositions of any signals that are being caught are reset to
      the default (signal(7)).