MySqlDataAdapter da = new MySqlDataAdapter("select * from mytable", con);
DataSet ds = new DataSet();
ds.Clear();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.Columns["id"].Visible = false;
dataGridView1.Columns["chk"].HeaderText ="Check";
这不起作用:
dataGridView1.Columns["chk"].CellTemplate = new DataGridViewCheckBoxCell();
答案 0 :(得分:0)
您需要添加一个实际的复选框列:
DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
dataGridView1.Columns.Add(checkColumn);