Windows中的ComboBox和checkboxList [英] ComboBox and checkboxList in windows
本文介绍了Windows中的ComboBox和checkboxList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在windows窗体中使用了combobox和checkboxlist,它的值相同。我在改变这些控件的选定值时面临一个问题。如果我在复选框列表中更改选定的值,则组合框选择的值也会在复选框列表中相同更改,反之亦然。我需要限制这个。请帮助我。
I am using combobox and checkboxlist in my windows form and its values are same. I am facing one issue while change the selected value of these controls. If I changing selected value in the checkboxlist, then the combobox selected value is also changed as the same in the checkboxlist and viceversa. I need to restrict this. Please help me.
推荐答案
尝试下面的代码:
Try below code:
DataTable dtAgencies = GetAgencies();
if (dtAgencies.Rows.Count > 0)
{
this.chkListChild.DataSource = dtAgencies;
this.chkListChild.DisplayMember = "agencyID";
this.chkListChild.ValueMember = "conString";
DataTable dtCopy = dtAgencies.Copy();
this.cmbParent.DataSource= dtCopy;
this.cmbParent.DisplayMember = "agencyID";
this.cmbParent.ValueMember = "conString";
}
希望它有所帮助!
Hope it helps!
使用dtAgencies .Copy()是个好主意。 chkListChild和cmbParent应绑定不同
Using a dtAgencies.Copy() is a good idea. chkListChild and cmbParent should be bound different
你应该添加额外的if条件来控制它...
组合框选择索引更改事件...
you should add extra if condition to control this...
combobox selected index change event...
if (YourComboboxName.Focused == true)
{
//checkbox selection-index code here
}
Checklistbox选择的索引更改事件......
Checklistbox selected index change event...
if (YourChecklistboxName.Focused == true)
{
//Combobox selection-index code here
}
快乐编码!
:)
Happy Coding!
:)
这篇关于Windows中的ComboBox和checkboxList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文