使用 C# 和 Visual Studio,我有一个DataGridView
有 2 列。对于每一行,第一列将显示文本。对于除特定行之外的每一行,第二列将显示文本。在第二列的一个特定单元格中,我需要显示一张图像。
例如:
Row[0].Cell[0] = "test" Row [0].Cell[1] = "test"
Row[1].Cell[0] = "test" Row [1].Cell[1] = "test"
Row[2].Cell[0] = "test" Row [2].Cell[1] = need to display an image here
Row[3].Cell[0] = "test" Row [3].Cell[1] = "test"
有不止一种方法可以做到这一点,但这里有一个简单的示例,它将设置一个单元格来显示图像:
Bitmap bmp = (Bitmap) Bitmap.FromFile(someimagefile);
DataGridViewImageCell iCell = new DataGridViewImageCell();
iCell.Value = bmp;
dataGridView1[1, 2] = iCell;
当然任何其他图像源也可以工作。
如果更改位图,请尽量不要泄漏它们。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)