我有一个组合框作为用户控件创建(它实际上由标签,组合框和文本框组成)。我试图绑定一个数据集的数据源组合框,但我一直ValueMember /显示器件上收到错误消息:组合框问题:无法绑定到新的值成员
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";
它吹起来,每当它击中值成员,我也得到上述的两个错误。我在用户控件中丢失了什么?对我来说,这应该是工作..(fyi - 信息数据源确实包含两列)
我试过了一堆不同的战术,没有成功。请帮忙!
谢谢
什么是'info'?你是否确定无论存储在那里有公共radiology_id和radiology_name? – kevev22 2012-02-23 21:40:15
我很积极。我在设置之前查看数据集。 – Encryption 2012-02-23 21:47:10
'info'是一个DataSet还是一个DataTable?如果它是一个DataSet,你将不得不将DataSource设置为所需的DataTable:'DataSource = info.Tables [0];' – kevev22 2012-02-23 21:51:56