如何获取Control Inside DataGridView列

时间:2013-05-14 12:46:08

标签: c# datagridview

如何在DataGridViewCheckBoxCell中获得类似于DataGridViewCheckBoxCell中的CheckBox之类的控件?

foreach (DataGridViewRow row in dgvPerformance.Rows)
{
   DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[6];
   //I need to find CheckBox in chk
}

1 个答案:

答案 0 :(得分:0)

您无法从CheckBox获得DataGridViewCheckBoxCell控件,但您可以获得其值:

foreach (DataGridViewRow row in dgvPerformance.Rows){
   DataGridViewCheckBoxCell chk = row.Cells[6] as DataGridViewCheckBoxCell;

   if(chk != null && (bool)chk.Value){
      //checked, do something
   }
}