Checkbox column in datagridview

Hello everybody

I have a DataGridView in a C# windows app that I have populated using a DataTable. It works fine for the most part, except when I come to save any changes I have made.

The only editable column is a checkbox column.
When the program is running, if I tick several checkboxes in the column and then save, all the data is saved correctly with the exception of the last box ticked.

I think what's happeneing is that the DataTable used to populate the grid isn't updated when you click the checkbox until the checkbox/grid cell loses focus. I think somehow if I click save direclty after clicking the checkbox, my save methods are running before the DataTable is updated, and so the change is not picked up.

How can I get the DataGridView to update the DataTable as and when the checkboxes are clicked?
Rusty_AdamsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Bob LearnedConnect With a Mentor Commented:
Sounds like you have a pending edit:

   this.dataGridView1.EndEdit();

Bob
0
 
Rusty_AdamsAuthor Commented:
Yep! That sorted it, cheers Bob!
0
All Courses

From novice to tech pro — start learning today.