private void btnActivate_Click(object sender, EventArgs e) { for (int i = 0; i < dataGridView1.RowCount; i++) { if ((bool)dataGridView1.Rows[i].Cells[0].Value != true && activate(i)) { dataGridView1.Rows[i].Cells[0].Value = true; } } }