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 AnsariRank #366 · 6.8K reputationPosted Aug 8, 2023, 1:59 PM EDT
int count = 0; for (int i = 0; i < dataGridView1.RowCount; i++) { if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value) == true) { count++; } } label6.Text = count.ToString();Mehmet FatihRank #1,475 · 1.1K reputationPosted Aug 8, 2023, 2:22 PM EDT
Thanks Tahir. It works fine.
Scott Stewart198 reputationPosted Aug 8, 2023, 1:45 PM EDT
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.
Mehmet FatihRank #1,475 · 1.1K reputationPosted Aug 8, 2023, 1:52 PM EDT
Sorry, I forgot to mention it. I am using DataGridViewCheckBoxColumn.