Good morning! I have my dataGrid that is filled with data from my database and I made an additional column of type checkbox so that certain marked orders are billed. But what happens to me is that I have to update an LBL according to the selected orders with their respective amounts and it only updates me when the selected cell loses focus and I need it to be when I select the value true or false directly. I tried the following code attached to the event dataGridView1_CellClick but it does not work, the value is always outdated. If I click on the value it is always the one that I had and not the new one.
decimal totalSelected = 0;
dataGridView1.Focus();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
DataGridViewCheckBoxCell cell = row.Cells[0] as DataGridViewCheckBoxCell;
if (cell.Value != null)
{
if (cell.Value == cell.TrueValue)
{
totalSelected += Convert.ToDecimal(row.Cells[3].Value);
}
}
}
lblTotalToPaid.Text = totalSelected.ToString("$0.00", CultureInfo.CurrentCulture);
}