110,537
社区成员
发帖
与我相关
我的任务
分享
foreach (DataGridViewRow row in this.dgvSteps.Rows)
{
PictureBox picBox = new PictureBox();
picBox.SizeMode = PictureBoxSizeMode.CenterImage;
//得到图片单元格区域
Rectangle rectangle = this.dgvSteps.GetCellDisplayRectangle(0, row.Index, true);
//设置PictureBox对象大小和位置
picBox.Bounds = new Rectangle(rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1);
Image img = row.Cells[0].Value as Image;
if (img != null)
{
picBox.Image = img;
}
this.dgvSteps.Controls.Add(picBox);
}