4

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

Kiran
  • 8,034
  • 36
  • 110
  • 176

4 Answers4

10

What worked for me:

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

or

this.dataGridView2.RefreshEdit();
this.dataGridView2.Refresh();
nfree25
  • 123
  • 1
  • 6
  • 1
    Please don't add "the answers X and Y worked for me" as answers. Invest some time in the site and you will gain sufficient [privileges](http://stackoverflow.com/privileges) to upvote answers you like, which is the Stack Overflow way of saying that something is helpful. – Nathan Tuggy Mar 03 '15 at 01:53
  • Noted. The second one is a combination of 2 solutions tho. – nfree25 Mar 04 '15 at 02:45
  • Not sure why adding the call to `RefreshEdit()` before calling `Refresh()` works, but it seems to have fixed the similar problem I was experiencing. – Jim Fell Jul 05 '16 at 12:59
6

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

Community
  • 1
  • 1
Silent Winter
  • 71
  • 1
  • 4
0

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

Kiran
  • 8,034
  • 36
  • 110
  • 176
0

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.

Ana
  • 63
  • 8