You can bind MultiSelect to a list of complex data objects which can have multiple properties. To bind the control to a list of data objects, follow these steps:
C# |
コードのコピー
|
---|---|
public class Customer { string name; string customerID; string mobile; string email; public Customer(string _name, string _custId, string _mobile, string _email) { this.name = _name; this.customerID = _custId; this.mobile = _mobile; this.email = _email; } public string Name { get { return name; } } public string CustomerID { get { return customerID; } } public string Mobile { get { return mobile; } } public string Email { get { return email; } } } |
C# |
コードのコピー
|
---|---|
private void Form1_Load(object sender, EventArgs e) { BindingList<Customer> customers = new BindingList<Customer>(); customers.Add(new Customer("John", "C001", "8888832141","john@gmail.com")); customers.Add(new Customer("Alex", "C002", "8888832142", "@gmail.com")); customers.Add(new Customer("Shawn", "C003", "8888832143", "shawn@gmail.com")); customers.Add(new Customer("Sam", "C004", "8888832144", "sam@gmail.com")); customers.Add(new Customer("Neo", "C005", "8888832145", "neo@gmail.com")); customers.Add(new Customer("Paul", "C006", "8888832146", "paul@gmail.com")); c1MultiSelect1.BindingInfo.DataSource = customers; c1MultiSelect1.BindingInfo.DisplayMemberPath ="Name"; } |