I have the following 2 classes:
public class CustomerList
{
public string Name { get; set; }
public ICollection<Customer> Customers { get; set; }
public CustomerList()
{
Customers = new List<Customer>();
}
}
public class Customer
{
public string Name { get; set; }
public string Surname { get; set; }
}
I have a form with a binding source, listview and 2 textbox controls. The datasource for the bindingsource if Customer. The datasource for the listview is the bindingsource itself, whilst the databindings for the textbox controls are the respective customer properties.
At runtime, the bindingsource datasource changes to:
customerList = new CustomerList();
bindingSource.Datasource = customerList.Customers;
I then start entering text in the controls and on click the Save button, I call 'bindingSource.EndEdit()'. However nothing is added?
Is this not the correct way to use a bindingsource with a list and editing controls?