且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Datagridview vb.net的同一单元格中添加图像和文本

更新时间:2023-12-03 11:52:46

也许您可以重载Cell Paint事件并手动加载图像并绘制文本?

Perhaps you could overload the Cell Paint event and manually load the image and draw the text?

paint事件为您提供了一个Graphics 对象,它具有用于此类事物的DrawString()方法。像这样的东西;假设Column2是DataGridViewImageColumn

the paint event gives you a Graphics object which has DrawString() methods for such things. Something like this; assuming Column2 is a DataGridViewImageColumn

                    using (Brush br = Brushes.Black)
                    {
                        Column2.Image = Image.FromFile(@"c:\tmp\capture.png");
                        e.Graphics.DrawString("Something.", this.Font, br, e.CellBounds);
                    }