日期:2014-05-17 浏览次数:21149 次
DataGridViewCheckBoxColumn c = new DataGridViewCheckBoxColumn();
c.HeaderText = "Mise En Vente";
c.Width = 150;
c.Name = "venteCheckBox";
dataGridViewOeuvres.Columns.Add(c);
for(int i=0; i< dataGridViewOeuvres.RowCount; ++i)
{
CheckBox ck = new CheckBox();
ck.Checked = Convert.ToInt32(dataGridViewOeuvres.Rows[i].Cells["miseEnVente"].Value)>0?true:false;
dataGridViewOeuvres.Rows[i].Cells["venteCheckBox"].Value = ck;
MessageBox.Show(dataGridViewOeuvres.Rows[i].Cells["venteCheckBox"].Value.ToString());
}
dataGridViewOeuvres.CellClick += DataGridCellClick;
void DataGridCellClick(object sender, DataGridViewCellEventArgs e)
{
if(dataGridViewOeuvres.Columns[e.ColumnIndex].Name == "venteCheckBox")
{
MessageBox.Show(dataGridViewOeuvres.Rows[e.RowIndex].Cells["venteCheckBox"].Value.ToString());
}
}