如何使用C#Windows窗体在DataGridView中插入PictureBox [英] how to insert PictureBox in dataGridView using C# Windows Forms

查看:180
本文介绍了如何使用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


< a href =http://social.msdn.microsoft.com/Forums/windows/en-US/4f3465b0-7126-4f86-b2e3-e5ecc336b1c8/how-to-show-animated-gif-images-in-datagridview? forum = winformsdatacontrols> how-to-show-animated-gif-images-in-datagridview [ ^ ]

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


这篇关于如何使用C#Windows窗体在DataGridView中插入PictureBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆