无法在DataGridView中显示多个图像 [英] Unable to display more than 1 image in DataGridView

查看:67
本文介绍了无法在DataGridView中显示多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用路径来检索将在DataGridView中显示的图像.如果我加载一张图像,那很好,如果我尝试加载2张或更多图像,则只有最后一张显示在DataGridView中.知道为什么会这样吗?
谢谢

Hi,

I''m using paths to retrieve images that will be displayed in a DataGridView. If I load one image, it''s fine, if I try to load 2 or more images, only the last one gets displayed in the DataGridView. Any idea why this is happening?
thanks

DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
dataGridView2.Columns.Insert(0, iconColumn); 
dataGridView2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCellsExceptHeader;
dataGridView2.Rows[0].Cells[0].Value = (Image)Bitmap.FromFile(@"C:\Documents and Settings\mbazinet\My Documents\Mathieu\Plans\Plans\Images\porteA_35.jpg");
dataGridView2.Rows.Add();
dataGridView2.Rows[1].Cells[0].Value = (Image)Bitmap.FromFile(@"C:\Documents and Settings\mbazinet\My Documents\Mathieu\Plans\Plans\Images\porteB_35.jpg");
dataGridView2.Rows.Add();
dataGridView2.Rows[2].Cells[0].Value = (Image)Bitmap.FromFile(@"C:\Documents and Settings\mbazinet\My Documents\Mathieu\Plans\Plans\Images\porteC_35.jpg");
dataGridView2.AutoResizeRows(DataGridViewAutoSizeRowsMode.DisplayedCells); 

推荐答案

检查datagridview属性"AllowUserToAddRows"是否设置为"True",然后设置为"False"


希望有帮助
check datagridview properties "AllowUserToAddRows" if it set "True" then set "False"


hope this help


这篇关于无法在DataGridView中显示多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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