DataTable not updating when clicked on CheckBox in DataGridView
When you have DataGridView with checkbox column and you click on the checkbox the underlying DataTable is not updated correctly. DataTable is only updated if you move to other row. Not sure why it's like that, but this is a workaround.
public void Save(){
DataTable dataTable1 = ((DataTable)dataGridView.DataSource).GetChanges();
//dataTable1 is NULL
//revalidate form (fixes the problem)
this.ValidateChildren();
DataTable dataTable2 = ((DataTable)dataGridView.DataSource).GetChanges();
//dataTable2 has correct values now
}
Comments
Post a Comment