日期:2014-05-17  浏览次数:21412 次

(winform)GridView 单元格显示system.drawing.bitmap 不显示图片
试过各种方法,图片单元格里面老是显示system.drawing.bitmap,不显示图片

MenuOutlookGrid.Columns.Add("column1", "名称");  
DataGridViewImageColumn colShow = new DataGridViewImageColumn();
colShow.Name = "Images";
colShow.HeaderText = "设置";
colShow.Width = 20;
colShow.Image = imageList1.Images[0];
MenuOutlookGrid.Columns.Add(colShow);
 
MenuOutlookGrid.Rows.Add(new object[] { "test", Image.FromFile(@"D:\edit.gif") });

//MenuOutlookGrid.Rows.Add(1);
//MenuOutlookGrid.Rows[0].Cells[0].Value = obj.Id;
//MenuOutlookGrid.Rows[0].Cells[1].Value = colShow.Image;//imageList1.Images[0];

//MenuOutlookGrid.Rows[0].SetValues(new object[] { "test", imageList1.Images[0] });

------解决方案--------------------
C# code

            DataGridViewImageColumn column1 = new DataGridViewImageColumn();
            dataGridView1.Columns.Add(column1);

            dataGridView1.Columns.Add("column2", "第二列");
            this.dataGridView1.Rows.Add(new object[] { Image.FromFile(@"C:\Users\huangha\Desktop\签名.png") ,"test"});