加入CheckBox
//DataGridView加入CheckBox
//DataGridView加入CheckBox
DataGridViewColumn colCheck = new DataGridViewCheckBoxColumn();
//設定寬度 colCheck.Width = 45;
//設定該行背景顏色 colCheck.CellTemplate.Style.BackColor = Color.Yellow;
//this.dataGridView1.Columns.Add(col); dataGridView1.Columns.Insert(0, colCheck);
CheckBox全選
private void button2_Click(object sender, EventArgs e){
//全選
for (int i = 0; i < dataGridView1.RowCount; i++)
{
dataGridView1.Rows[i].Cells[0].Value = true;
}
}
CheckBox全部取消
private void button3_Click(object sender, EventArgs e)
{
//取消
for (int i = 0; i < dataGridView1.RowCount; i++)
{
dataGridView1.Rows[i].Cells[0].Value = false;
}
}
private void button3_Click(object sender, EventArgs e)
{
//取消
for (int i = 0; i < dataGridView1.RowCount; i++)
{
dataGridView1.Rows[i].Cells[0].Value = false;
}
}
沒有留言:
張貼留言