源码:DataGridViewRow row = new DataGridViewRow();
DataGridViewCheckBoxColumn dgcbc1 = new DataGridViewCheckBoxColumn();
dataGridView1.Columns.Add(dgcbc1);
dgcbc1.Name = "dgcbc1";
dgcbc1.HeaderText = "选择";
dgcbc1.DataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
DataGridViewCheckBoxColumn dgcbc2 = new DataGridViewCheckBoxColumn();
dataGridView1.Columns.Add(dgcbc2);
dgcbc2.Name = "dgcbc2";
dgcbc2.HeaderText = "文字1";
dgcbc2.DataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
DataGridViewCheckBoxColumn dgcbc3 = new DataGridViewCheckBoxColumn();
dataGridView1.Columns.Add(dgcbc3);
int temp = 0;
List ls = new List();
for (int i = 0;i< 4; i++){
ls.Add("asa");
}
IEnumerator ie = ls.GetEnumerator();
while (ie.MoveNext())
{
temp += 1;
DataGridViewCheckBoxCell checkBoxCell = new DataGridViewCheckBoxCell();
row.Cells.Add(checkBoxCell);
dataGridView1.Rows.Add(row);
}
row.Cells.Add(new DataGridViewCheckBoxCell());