我们如何在使用C#选择combobox1中的下一个项目时清除combobx2中的数据 [英] How can we clear data in combobx2 on selecting next item in combobox1 using C#
本文介绍了我们如何在使用C#选择combobox1中的下一个项目时清除combobx2中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi,
I used two combo boxes cmbhospitals and cmbusers in cmbusers when i click hospital A in 1st combbox it displays users of that hospital but again when i click on hospital B in cmbusers(Combobox2) it was displaying both users og hospital A and B I used if which clears the text but not the previous hosptal data please suggest
我尝试过:
What I have tried:
//cmbhusers.SelectedItem=null;
cmbhusers.Items.Clear();
cmbhusers.ResetText();
cmbhusers.selectedIndex=-1;
推荐答案
在您的点击事件中,您需要在添加之前清除组合框2它的新项目。花一些时间研究 ComboBox类(System.Windows。表格) [ ^ ],因为这似乎是给你带来最多麻烦的课程。
In your click event you need to clear combo box 2 before you add the new items to it. Spend some time studying ComboBox Class (System.Windows.Forms)[^], as this seems to be the class that is giving you most trouble.
这篇关于我们如何在使用C#选择combobox1中的下一个项目时清除combobx2中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文