3
Answers

Delay of display

Dan Condes

Dan Condes

6y
485
1
Hello,
 
I'm making a program that displays records in a datagridview. This rows has a checkbox so the user can tick what row they like.
 
I want to display the number of selected items (the one the ticked) upon ticking the checkbox row.
 
Here is my code on counting the checked rows. But the update of the text label for the count do not happen right after I tick the box.
 
what should i do?
 
public void DisplaySelectedMSGFiles() {
int check_ctr =0;
DataGridViewCheckBoxCell oCell;
foreach (DataGridViewRow r in dgmsgfiles.Rows)
{
oCell = r.Cells[0] as DataGridViewCheckBoxCell;
if (oCell.Value!=null && oCell.Value.ToString() != "Unchecked" && oCell.Value.ToString() != "False")
{
check_ctr += 1;
}
}
lblselectedmsgfiles.Text = String.Format("{0} of {1} item selected", check_ctr,dgmsgfiles.RowCount);
}
Answers (3)