DataGridView设置指定单元格为Button按钮
程序员文章站
2022-07-13 13:36:49
...
//设置指定单元格为Button按钮
this.GridView_SetLayerRule.Controls.Clear();
for (int i = 0; i < GridView_SetLayerRule.Rows.Count; i++)
{
System.Windows.Forms.Button btn = new System.Windows.Forms.Button();//创建Buttonbtn
string cellVaule = GridView_SetLayerRule.Rows[i].Cells[0].Value.ToString();
if (cellVaule != "微小线检查规则" && cellVaule != "微小面检查规则") continue;
btn.Text = "设置条件";
btn.Font = new System.Drawing.Font("宋体", 10);
btn.Visible = true;
btn.Width = this.GridView_SetLayerRule.GetCellDisplayRectangle(1, i, true).Width;
btn.Height = this.GridView_SetLayerRule.GetCellDisplayRectangle(1, i, true).Height;
this.GridView_SetLayerRule.Controls.Add(btn);
btn.Location = new System.Drawing.Point(((this.GridView_SetLayerRule.GetCellDisplayRectangle(1, i, true).Right) -
(btn.Width)), this.GridView_SetLayerRule.GetCellDisplayRectangle(1, i, true).Y);//设置btn显示位置
}
上一篇: 数据集___