首页 > 其他分享 >DataGridview 全选框

DataGridview 全选框

时间:2022-11-28 15:26:33浏览次数:42  
标签:CheckBox 18 DataGridview cbHeader Location new rect 选框

#region 建立全选 CheckBox For gridDnList

//建立个矩形,等下计算 CheckBox 嵌入 GridView 的位置
Rectangle rect = gridDnList.GetCellDisplayRectangle(0, -1, true);
rect.Size = new Size(18, 18);
rect.X = rect.Location.X + rect.Width / 4 + 6;
rect.Y = rect.Location.Y + (rect.Height / 2 - 9) + 6;

CheckBox cbHeader = new CheckBox();
cbHeader.BackColor = System.Drawing.Color.Transparent;
cbHeader.UseVisualStyleBackColor = false;
cbHeader.Name = "checkboxHeader";
cbHeader.Size = new Size(18, 18);
cbHeader.Location = rect.Location;
//全选事件
cbHeader.CheckedChanged += new EventHandler(cbHeader_CheckedChanged);

//将 CheckBox 加入到 dataGridView
gridDnList.Controls.Add(cbHeader);

#endregion

标签:CheckBox,18,DataGridview,cbHeader,Location,new,rect,选框
From: https://www.cnblogs.com/guxia/p/16932252.html

相关文章