CheckBox CkBox = new CheckBox();
#region 初始化加载
private void aaControl_Load(object sender, EventArgs e)
{
//绘制勾选框
CkBox.Text = "";
CkBox.Checked = false;
CkBox.BackColor = GridDiag.ColumnHeadersDefaultCellStyle.BackColor;
Rectangle rect =
GridDiag.GetCellDisplayRectangle(6, -1, true);
CkBox.Size = new Size(18, 18);
CkBox.Location = new Point(rect.Location.X + 32, rect.Location.Y + (GridDiag.ColumnHeadersHeight - 18) / 2);
CkBox.CheckedChanged += new EventHandler(CkBox_CheckedChanged);
GridDiag.Controls.Add(CkBox);
}
/// <summary>
/// 医保是否上传的全选和取消
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CkBox_CheckedChanged(object sender, EventArgs e)
{
if (null == GridDiag.Rows || GridDiag.Rows.Count <= 0)
{
return;
}
//防止当前行不选中EndEdit不知道为啥不行
GridDiag.CurrentCell = null;
//全选的复选框选中
if (CkBox.Checked == true)
{
//选中全部
for (int i = 0; i < this.GridDiag.Rows.Count; i++)
{
this.GridDiag.Rows[i].Cells["ybsfsc"].Value = FrameCodes.SF.Y;
}
}
// 全选的复选框取消
else
{
//全部取消
for (int i = 0; i < GridDiag.Rows.Count; i++)
{
this.GridDiag.Rows[i].Cells["ybsfsc"].Value = FrameCodes.SF.N;
}
}
}
#endregion