在DataGridView图像列中显示多个图像?可能吗?

时间:2011-03-30 22:29:26

标签: datagridview

是否可以在DataGridViewImageColumn的列中显示多个图像?我只有1列,需要动态显示图像。此列可以显示1到3张图像,具体取决于其他条件。

2 个答案:

答案 0 :(得分:3)

您可以将要显示的两个图像绘制到第三个新图像上,然后在列中显示该图像。

这样的事情:

        Bitmap Image1 = new Bitmap(10, 10); //replace with your first image
        Bitmap Image2 = new Bitmap(10, 10); //replace with your second image
        Bitmap ImageToDisplayInColumn = new Bitmap(Image1.Width + Image2.Width, Image1.Height);
        using (Graphics graphicsObject = Graphics.FromImage(ImageToDisplayInColumn))
        {
            graphicsObject.DrawImage(Image1, new Point(0, 0));
            graphicsObject.DrawImage(Image2, new Point(Image1.Width, 0));
        }

答案 1 :(得分:2)

有几篇关于创建自定义DataGridViewColumns的文章。这是来自CODE magazine的一个。听起来您想编写自己的代码来使用适当的图像或图像绘制列。

相关问题