I have been researching for hours on this topic and can't seem to get to a solution or reasonable explanation as why it doesn't work. I've found similar posts but none address what I'm looking for. This post helped me the most as far as understanding how it works. I was even able to successfully test this using a TextBox. Problem is I'd like this feature for my DataGridview. I'd like to make changes in the DataGridView but not have the List updated until clicking like an "Ok" button. I've been using this test setup:
Simple class:
public class Person
{
public int Age { get; set; }
public int Height { get; set; }
public Animal(int age, int height)
{
Age = age;
Height = height;
}
}
I setup the databinding as usual. Snippet from my Form constructor:
public Form1()
{
InitializeComponent();
People = new List<Person>();
personBindingSource.DataSource = People;
personBindingSource.RaiseListChangedEvents = true;
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = personBindingSource;
dataGridView1.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.Never;
}
I edit the cell with a value and then have a button that calls the Binding.WriteValue(). The underlying datasource keeps getting automatically updated with the cell changes (Behaving like OnValidation even though I've made it Never literally everywhere I can think of). Is there something I'm missing or am I going to have to manually implement this?
Aucun commentaire:
Enregistrer un commentaire