我创建了一个作为用户控件的组合框(它实际上由标签、组合框和文本框组成)。我正在尝试将数据集绑定到组合框数据源,但我不断收到有关 ValueMember/Display 成员的错误消息:
Cannot bind to the new display member - newdisplay member
Cannot bind to the new value member - parameter name: value
我以为我已经为用户控件正确编码了所有内容:
public partial class ucComboBox : UserControl
{
#region Properties (6)
private bool isEditableReadOnly;
private bool ArrVisible;
private string _value;
private string _name;
public string value
{
get { return _value ; }
set { _value = value; }
}
public string name
{
get { return _name; }
set { _name = value; }
}
}
我在用户控件中有一些其他属性和事件,但它们不应该是问题。
我的绑定信息的代码:
((ucComboBox)ctrl).combobox.DataSource = info;
((ucComboBox)ctrl).combobox.ValueMember = "radiology_id";
((ucComboBox)ctrl).combobox.DisplayMember = "radiology_name";
每当它击中值成员时它就会爆炸,并且我收到上述两个错误。我的用户控件中是否缺少某些内容?在我看来这应该有效..(仅供参考 - 信息数据源确实包含两列)
我尝试了很多不同的策略但没有成功。请帮忙!
Thanks
还要确保 ID 和 Name 属性是Public否则你会得到错误:
Cannot bind to the new display member.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)