Wednesday, April 16, 2008

CheckAll checkbox in GridView

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)

{

if (e.RowIndex == -1 )

{

int i;

for (i = 0; i <>

{

this.dataGridView1.EndEdit();

string re_value = this.dataGridView1.Rows.Cells[0].EditedFormattedValue.ToString();

this.dataGridView1.Rows.Cells[0].Value = "true";

this.dataGridView1.Rows.Selected = true;

}

}

}

=============================================================

private void checkBox1_CheckedChanged(object sender, EventArgs e) {

foreach (DataGridViewRow row in dataGridView1.Rows)

row.Cells[0].Value = checkBox1.Checked;

}

No comments: