动态BindingSource如何 [英] Dynamic BindingSource how to
问题描述
大家好,
我想用两个组合框设置动态bindingSource,当我添加这一行时:
I want to set dynamic bindingSource with two comboboxes , when i add this line:
;
_toComboBox.DataBindings.Add("SelectedValue", tb_DosetsBindingSource, "_to");
它会引发异常,所以如何成功设置动态绑定
it raises an exception , so how can i set dynamic binding succefully
谢谢
Thanks
Esmat
推荐答案
Esmat,带有组合框你不能使用DataBinding(这是一个项目),但因为它似乎你使用Windows窗体
Esmat, with a combobox you must not use DataBinding (that is for one item) but as it seems you use windows forms
DataSource和displaymember以及如果需要的值成员
DataSource and displaymember and if needed valuemember
comboBox1.DataSource = YourSource
comboBox1.DisplayMember = "TheNameOfThePropertyInTheSource";
comboBox1.ValueMember = "TheNameOfThePropertyTheSource";
请注意,按照惯例,对于C#下划线是属于属性的项目。
Be aware that for C# by convention the underscore is for items which are base of a property.
如果是关于WPF而不是自己查找Itemsource(其余几乎相同)
If it is about WPF than look for Itemsource yourself (the rest is almost the same)
如果是数据网格视图,您还需要DataPropertyName
If it is for a datagridview you also need the DataPropertyName
这篇关于动态BindingSource如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!