I have a bound DataGridView which contains a CheckBoxColumn (a default column based on the bound data source). In my application, I allow the user to select the checkbox cell over multiple rows. Whenthe user changes one of the cells with ctrl+click, all the selected cells change to match that value.

In the form which contains the dgv, I also display a button which changes color when the contents of the bound DataTable changes. This allows them to see that modifications have been made. Clicking the button moves the DataTable changes to the database.

The problem I'm having is that while selecting the cells in the checkboxcolumn, the third cell selection (always the third one) results in a change in the DataTable. In my case, all the selected checkbox cells are in the same state (checked). During the CellEndEdit eventall the selected cells are compared against the cell which fired the event. Now - I can step through this and see that the edited cell has a value of 'true', and that the cell it is being compare to (a different cell) also has a value of 'true'. However when I view this in the debugger "c.Value == cEdit.Value" it resolves to 'false'.

Each of their Values shows the same value in the watch window, as do each of their ValueTypes, and the column they belong to, and the TrueValue properties.

Here's some code:

void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)

{

// Clear the row error in case the user presses ESC.

dataGridView1.Rows[e.RowIndex].ErrorText = String.Empty;

// MultiSelect code to copy edit cell to other selected cells

if (m_bMultiEdit)

{

DataGridViewCell cEdit = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];

foreach (DataGridViewCell c in dataGridView1.SelectedCells)

{

if (c.ColumnIndex == e.ColumnIndex && c.RowIndex != e.RowIndex)

{

Both these values show 'true' but the 'if' block is executee!

if (c.Value != cEdit.Value)

{

c.Value = cEdit.Value;

}

}

}

}

}

Any ideas?