Cannot edit values of DataGridView bound to a BindingList

Posted by m_oLogin on Stack Overflow See other posts from Stack Overflow or by m_oLogin
Published on 2010-04-30T23:10:38Z Indexed on 2010/04/30 23:17 UTC
Read the original article Hit count: 327

Hello community,

I have trouble editing a databound bindinglist. Let me illustrate it with the following:

Say I have the Person class:

public Class Person{
  private string m_firstname;
  private string m_lastname;
  public string FirstName{get;set;}
  public string LastName{get;set;}
  public Person{ ... }
}

I then have a containing class called Population:

public class Population{
  private BindingList<Person> m_lstPerson = new BindingList<Person>();
  private string m_countryName;
  public BindingList<Person> ListPerson{get; set;}
  public string CountryName { get; set; }
}

I then have on one form a first datagridview with DataSource = m_lstPopulation (BindingList). The binding works like a charm when working with the Population objects. When I double click, it opens up a dialog form showing the object details. One tab in the details holds a datagridview bound to that population's ListPerson.

The second datagridview displays fine. However, I cannot edit or add cells in this datagridview. None of the columns is set to read-only. In fact, both datagridview have just about the same parameters.

What am I missing? It seems that a lock has been placed on the Population object so that its inner fields cannot be edited...

Please advise. Thanks.

© Stack Overflow or respective owner

Related posts about winforms

Related posts about datagridview