所以我有一堂课叫CustomerCollection
class CustomerCollection
{
public List<Customer> Customers { get; private set; }
...
}
有一个列表customers
class Customer
{
public String ID { get; private set; }
public String Name { get; private set; }
public Customer(String id, String name)
{
ID = id;
Name = name;
}
}
是否可以绑定一个组合框和一个文本框,以便组合框将显示 in 的所有可能 id,Customers
而Customer Collection
文本框将显示所选客户的姓名?
编辑:所以这就是我尝试过的
private void InitializeCustomerCollection()
{
var customerCollection = new CustomerCollection();
cmbx_custID.DataSource = customerCollection.Customers;
}
但这不起作用并导致组合框被填充
X.Collections.Customer
X.Collections.Customer
X.Collections.Customer