I want to get the number of checked checkboxes. I tried to do it with the codes below, but I could not succeed..
int count = 0;
for (count = 0; count <= dataGridView1.RowCount; count++)
{
if (Convert.ToBoolean(dataGridView1.Rows[count].Cells[0].Value) == true)
{
count++;
label6.Text = (count.ToString());
}
}
Tahir AnsariPosted Aug 8, 2023, 5:59 PM
Mehmet FatihPosted Aug 8, 2023, 6:22 PM
Thanks Tahir. It works fine.
Mehmet FatihPosted Aug 8, 2023, 5:52 PM
Sorry, I forgot to mention it. I am using DataGridViewCheckBoxColumn.
Scott StewartPosted Aug 8, 2023, 5:45 PM
What is your source for the data grid view? If it is an Observable Collection, then it would probably be best to look though the collection for the checked (true) values.