【发布时间】:2011-05-03 23:45:35
【问题描述】:
我在数据绑定后向 DGV 单元添加图像时遇到问题。
这是我的代码:
DataTable tab = conn.searchData(searchTmp);
bindingSource1.DataSource = tab;
DGV.AllowUserToAddRows = false;
DGV.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
//dont show this colls
DGV.Columns["zId"].Visible = false;
DGV.Columns["tId"].Visible = false;
DGV.Columns["tId2"].Visible = false;
DataGridViewImageColumn co = new DataGridViewImageColumn();
System.Reflection.Assembly thisExe;
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream file = thisExe.GetManifestResourceStream("MyApp.Resources.Tx1[k].gif");
System.IO.Stream file2 = thisExe.GetManifestResourceStream("MyApp.Resources.Tx2[k].gif");
// 其他所有列 -- 第一个灰色行
Bitmap bmp = new Bitmap(file);
co.Image = bmp;
DataGridViewImageColumn img = new DataGridViewImageColumn();
Image image = bmp;
img.Image = image;
DGV.Columns.Add(img);
img.HeaderText = "Image";
img.Name = "img";
数据表是数据库的结果,
在第一个 coll 我有 TeX 表达式——我想用“MimeTex.dll”为这个表达式生成图像,我知道怎么做,但我不知道如何用图像替换这个 TeX 表达式,
屏幕上是我的原始 DGV,没有图像。
在最后六行中,我有一部分用于添加新列的代码,因为我测试并尝试如何用来自应用程序资源的静态图像替换第一行列文本(标题行)但没有成功......
有什么想法吗? TIA 屏幕 : http://www.freeimagehosting.net/image.php?66fe2964fe.jpg
【问题讨论】:
标签: c# image datagridview cell formatting