简体   繁体   English

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

[英]how to do: what i pick on combobox1 will show on combobox2?

how to do: what i pick on combobox1 will show on combobox2 ? 怎么做:我在combobox1上选择的内容将显示在combobox2上?

is it possible ? 可能吗 ? (in C#) (在C#中)

thank's in advance 提前致谢

You need to subscride second combobox on the SelectedIndexChanged event of the first combobox and change value when event triggers. 您需要在第一个组合框的SelectedIndexChanged事件上替代第二个组合框,并在事件触发时更改其值。 Also you need to make sure that both combobox have several items or you will need to add missing items to second combobox dynamically. 另外,您还需要确保两个组合框都包含多个项目,否则您将需要动态地将缺少的项目添加到第二个组合框中。

Event handler example: 事件处理程序示例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过选择comboBox1中的条件来存储来自comboBox2的数据并检索到comboBox2中 - How to store data from comboBox2 and retrieve into comboBox2 by selecting a condition in comboBox1 ComboBox2 获取 ComboBox1 函数中的字段 - ComboBox2 get fields in function of ComboBox1 从combobox1获取combobox2的值 - Get value of combobox2 from combobox1 如果combobox1和combobox2为true,则更新combobox3中的项目 - If combobox1 and combobox2 is true then update the items in combobox3 通过ComboBox1和ComboBox2的选定值筛选ComboBox3 - Filtering ComboBox3 by the selected values of ComboBox1 and ComboBox2 根据Combobox1所选项目填充ComboBox2 - Populate ComboBox2 depending on Combobox1 selected item 当我选择 combobox1 最后一个值时,combobox2 最后一个值将被自动选择 - When i select the combobox1 last value the combobox2 last value will be automatically selected 当我更改combobox1时,它也会同时更改combobox2中的值(都使用相同的List) - when I change combobox1 it also changes the values in combobox2 (both use the same List) 如何将combobox1项目从form1传递到form2中的combobox2 - How to pass combobox1 items from form1 to combobox2 in form2 C#-如何使用DataSet通过ComboBox1的ValueMember筛选ComboBox2数据 - C# - How to filter ComboBox2 data by ValueMember of ComboBox1 using DataSet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM