如何显示相关的组合框c#表格 [英] How to show related combo boxes c# forms

查看:95
本文介绍了如何显示相关的组合框c#表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天



我有两个Comboboxes,一个用于Item,另一个用于Type.Now in Item i有3个东西Air,Road,Sea in type我有



JetG5,梦想飞机,AirBus,梅赛德斯,Madza,丰田,潜艇和船只等



现在,当我选择Air时我想要JetG6,Dream衬里只出现,当我选择道路Air,Road,Sea出现时



我该怎么做?

Good day

I have two Comboboxes one is for Item and the Other is for Type.Now in Item i have 3 things Air, Road ,Sea in type i have

JetG5,Dreamliner,AirBus,Mercedes,Madza,Toyota,submarine ship and boat e.t.c

Now ,How when i choose Air i want JetG6,Dream liner only to appear and when I choose road Air ,Road ,Sea to appear

how do i do this?

推荐答案

我假设最初加载了所有 ComboBoxes



现在处理 ComboBox.SelectedIndexChanged 事件 [ ^ ]。在事件内部,查看所选值是什么。确定需要从其他 ComboBox 中删除​​的内容。



现在,从其他<$中移除该项目c $ c> ComboBox ,如下所示...

I assume that all the ComboBoxes are loaded initially.

Now handle the ComboBox.SelectedIndexChanged Event[^]. Inside the event, see what is the selected value. Decide what needs to be removed from the other ComboBox.

Now, to remove the item from other ComboBox, do like below...
// To remove "Tokyo" item:
comboBox1.Items.Remove("Tokyo");



参考 - 如何:在Windows窗体中添加和删除项目 ComboBox ListBox ,或 CheckedListBox 控制 [ ^ ]


检查出来:c-sharp-combobox-options-dependent-on-another-combobox [ ^ ]


这篇关于如何显示相关的组合框c#表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆