DataGridViewCheckBoxColumn dg = new DataGridViewCheckBoxColumn(); dg.HeaderText = "选择"; dg.Width = 50; dataGridView1.Columns.Add(dg);
添加 table里直接添加 checkbox
DataTable dt = new DataTable(); dt.Columns.Add("文件名"); foreach (string str in lstr) { DataRow dr = dt.NewRow(); dr[0] = str; dt.Rows.Add(dr); } DataGridViewButtonColumn button = new DataGridViewButtonColumn(); button.HeaderText = "操作"; button.Text = "单独导出"; button.UseColumnTextForButtonValue = true; dataGridView1.DataSource = dt; dataGridView1.Columns.Add(button); dataGridView1.Columns["文件名"].Width = 200;
同理