Kiran
Kiran

Reputation: 8528

Checkbox in the Datagridview not updating

I am using a Datagridview in a winform and using Virtual Mode to populate the unbound data.

I have a checkbox header, with a static checkbox. When I click on the checkbox, all the checkbox status is toggled.

However, the check status is not refreshed. I need to hover over the Datagridview to refresh the status of the checkbox.

When earlier, the Virtual mode was set to false, I was not having this problem. Any idea, if I am missing something.

enter image description here

Upvotes: 5

Views: 8927

Answers (4)

nfree25
nfree25

Reputation: 163

What worked for me:

this.dataGridView2.CurrentCell = null (thanks silent winter)

or

this.dataGridView2.RefreshEdit();
this.dataGridView2.Refresh();

Upvotes: 14

Ana
Ana

Reputation: 61

If the checkbox on the header is a child-control of the datagridview use the RefreshEdit method to refresh the results. I had the same issue recently.

Upvotes: 0

Silent Winter
Silent Winter

Reputation: 81

Just to note, the Refresh() didn't work for me. I had to use this.dataGridView2.CurrentCell = null

DataGridView -Value does not gets saved if selection is not lost from a cell

Upvotes: 7

Kiran
Kiran

Reputation: 8528

I am posting the answer for future reference and for users who might be facing similar issues.

Adding this.dataGridView2.Refresh(); in the checkbox changed eventhandler fixed the issue.

Thanks

Upvotes: 0

Related Questions