单击datagridview一列的列标题的事件怎么写的呢?我要实现checkbox的全选和反选?
单击datagridview一列的列标题的事件怎么写的呢?我要实现checkbox的全选和反选?
------解决方案--------------------Refer:
http://www.cnblogs.com/insus/archive/2013/05/22/3093114.html
http://www.cnblogs.com/insus/articles/1411613.html
------解决方案--------------------网上太多了。。。。。
------解决方案--------------------datagridview不是winform中的吗?怎么到asp.net区来问?
dgv1.EndEdit();
foreach (DataGridViewRow dgvr in dgv1.Rows)
{
dgvr.Cells["Check"].Value = checkState;
}
Check就是你的列名
------解决方案--------------------#region 选择CheckBox
DatagridViewCheckBoxHeaderCell cbhCell = new DatagridViewCheckBoxHeaderCell();
cbhCell.OnCheckBoxClicked += new CheckBoxClickedHandler(cbhCell_OnCheckBoxClicked);
DataGridViewCheckBoxColumn cbCheck = new DataGridViewCheckBoxColumn();
cbCheck.HeaderCell = cbhCell;
cbCheck.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
cbCheck.ReadOnly = false;
cbCheck.Name = "Check";
cbCheck.Width = 40;
cbCheck.HeaderCell.Value = string.Empty;
#endregion