public int countcheck() { int count = 0; foreach (DataGridViewRow row in dgv_Question.Rows) { if (row.Cells["Check"].Value != null && (bool)row.Cells["Check"].Value == true) { count++; } } return count; }