ComboBox 绑定customers( IList<CustomInfo> customers = new List<CustomInfo>();) 报错
IList<CustomInfo> customers = new List<CustomInfo>();//CustomerInfo是客户实体类
customers=customer.GetCustomers();//取所有客户信息
cbxCustomer.DataSource = customers;//cbxCustomer是ComboBox控件--------报错:
未将对象引用设置到对象的实例cbxCustomer.ValueMember = "CustomerID";
cbxCustomer.DisplayMember = "CustomerName";
------解决方案--------------------这样看不出来啊,代码再全些。
你可以在报错的这句上添加个断点,然后看看customers的当前内容是什么
------解决方案--------------------CustomInfo 客户实体类里定义属性了吗?
string _customerId;
string CustomerId
{
get{return _customerId;}
set{_customerId=value;}
}