Cannot edit DataGridView values ​​bound to BindingList

I'm having a hard time editing anchor-to-anchor binding. Let me illustrate this as follows:

Let's say I have a 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{ ... }
}

      

Then I have a 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; }
}

      

Then I have one form of the first datagridview with DataSource = m_lstPopulation

(BindingList). Binding works like a charm when working with Population objects. When I double-click, a dialog box opens showing the details of the object. One tab in details contains the datagridview binding to this ListPerson group.

The second datagridview file displays fine. However, I am unable to edit or add cells to this datagridview. None of the columns are readable. In fact, both datagridviews have roughly the same parameters.

What am I missing? It seems that the castle has been placed in a Population object so that its internal margins cannot be edited ...

Please advise. Thanks.

+2


a source to share


1 answer


First, make sure these grid properties are set:

ReadOnly = false; AllowUserToAddRow = true; EditMode =;



If that doesn't work, you might get stuck in edit mode ... It looks like you have some custom behavior in your mesh ("When I double click, a dialog opens showing the details of the object.") ...

To do this, try calling DataGridView.CancelEdit () after the dialog is closed to end the editing session on the row clicked. This will restore the newline to the grid. It disappears when you start editing another line, which, depending on the EditMode parameter, may start when you press (enter) another line.

+1


a source







All Articles