I was in front of the game is a C + + now in C # to do some unfamiliar may understand the wrong welcome to the paper
private void Btnselectorcancel_click (object sender, EventArgs e)
{
BOOL isChecked = false;
foreach (DataGridViewRow gvrow in Dgvdata.rows)
{
String strstate = Gvrow.cells[dgvdata.columncount-1]. Value.tostring ();
if (! ( Strstate.compareto ("True") = = 0 | | Strstate.compareto ("true") = = 0))
{
IsChecked = true;
Break
}
}
for (int i = 0;i < Dgvdata.rowcount;++i)
{
Dgvdata.rows[i]. CELLS[DGVDATA.COLUMNCOUNT-1]. Value = isChecked;
}
}
There's a problem with this code. When one of my cells is clicked and then click to select All, the view of the cell has not changed. I hit the log constantly debugging to find the data is right guess is the view is not updated or the data cache problem.
So I looked at the related properties of DataGridView, which had an attribute CurrentCell. This property will become the cell when you click on a cell. At this point we only need to set the value of our DataGridView CurrentCell to null at the start of the Select button click event. The problem is solved. In fact, there is another way to manipulate the data source. This way everyone should understand this and not explain it.
A small question about C # DataGridView Select All and Cancel