如何使用C#Windows窗体在DataGridView中插入PictureBox

如何使用C#Windows窗体在DataGridView中插入PictureBox

问题描述:

private void PicBox()
{
Image img = Image.FromFile(@"D:\Work\process.gif");
pictureBox1.Image = img;
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
}



这是我要在数据网格视图中插入的图片,我想在gridView中插入图片框的原因是图片是GIF和在我使用之前使用之前是动画的。


this is Picture I want to insert in data grid view, the reason i want to insert the picture box in gridView is that the Picture is GIF and is animated, before i have used before i have use

DataGridViewImageColumn img = new DataGridViewImageColumn();
dataGridView1.Columns.Add(img);
dataGridView1.Rows.Add();



它工作正常,但使用此图片不会在列中显示动画,而是使用PictureBox可以显示动画。



问候。


it works fine, but using this the picture does not show the animation in the column, but by using PictureBox the animation could be shown.

Regards.

Bitmap img;
img = new Bitmap(@"c:\images\mousepad.jpg");
// Create the DGV with an Image column
DataGridView dgv = new DataGridView();
this.Controls.Add(dgv);
DataGridViewImageColumn imageCol = new DataGridViewImageColumn();
dgv.Columns.Add(imageCol);
// Add a row and set its value to the image
dgv.Rows.Add();
dgv.Rows[0].Cells[0].Value = img;



也许这会对你有所帮助:)



-KR


Maybe this would help you :)

-KR


how-to-show-animated-gif-images-in-datagridview [ ^ ]

show-animated-gif-in-datagridview [ ^ ]