dear sir
image url :- 
https://ibb.co/hmBXxk
this is a window form data grid view there is checkbox in grid view and having event CellContentClick
my problem is that when i click on first check box status is :- first checkbox selection : false
then clicked on secound check box status is :- first checkbox selection : true secound checkbox selection : false
this things is happening again and again means last checked checkbox box i am getting false
below are the code
/// this code for populaing gridTest
private void listDepartment_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
gridTest.Columns.Clear();
if (listDepartment.SelectedItems.Count > 0)
{
string result = listDepartment.SelectedItems[0].SubItems[0].Text;
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "SELECT Code FROM tblTestHeader WHERE (Dept = '"+result+"')";
DataTable dt = DataUtility.ExeReader(cmd);
gridTest.DataSource = dt;
}
DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();
checkBoxColumn.HeaderText = "";
checkBoxColumn.Width = 30;
checkBoxColumn.Name = "checkBoxColumnListDepartment";
gridTest.Columns.Insert(0, checkBoxColumn);
}
catch (Exception ex)
{
MetroFramework.MetroMessageBox.Show(this, ex.ToString());
}
//string result = listDepartment.SelectedItems;
//MetroFramework.MetroMessageBox.Show(this, result);
}
// this code for checkbox click event
private void gridTest_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string messag = string.Empty;
foreach (DataGridViewRow row in gridTest.Rows)
{
bool isChecked = Convert.ToBoolean(row.Cells["checkBoxColumnListDepartment"].Value);
// bool isChecked = (Boolean)gridTest[0, e.RowIndex].FormattedValue;
if (isChecked)
{
messag += Environment.NewLine;
messag += row.Cells["Code"].Value.ToString();
}
}
MetroFramework.MetroMessageBox.Show(this, messag);
}