c# winform checkbox选中数
当我单击DataGridView中的CheckBox,用什么事件可以获取DataGridView中CheckBox选中的个数。
代码如下:
ArrayList arr = new ArrayList();
foreach (DataGridViewRow dgvrow in dtGridGroup.Rows)
{
DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)dgvrow.Cells["sel"];
Boolean fag = Convert.ToBoolean(chk.EditedFormattedValue);
if (fag == true)
{
arr.Add(true);
}
}
txt_People.Text = arr.Count.ToString();