怎么办:我在combobox1上选择的内容将在combobox2上显示?

时间:2010-03-20 18:35:51

标签: c#

怎么做:我在combobox1上选择的内容将显示在combobox2上?

有可能吗? (在C#中)

提前谢谢

1 个答案:

答案 0 :(得分:3)

您需要在第一个组合框的SelectedIndexChanged事件上包含第二个组合框,并在事件触发时更改值。此外,您需要确保两个组合框都有多个项目,或者您需要动态地将缺少的项目添加到第二个组合框中。

事件处理程序示例:

    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        object selectedValue = this.comboBox1.SelectedValue;
        this.comboBox2.SelectedValue = selectedValue;
    }