在Datagridview vb.net的同一单元格中添加图像和文本 [英] Adding Image and Text in a same cell of a Datagridview vb.net

查看:96
本文介绍了在Datagridview vb.net的同一单元格中添加图像和文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提前致谢,

我想在vb.net的datagridview的同一单元格上显示文字和图片,我做了一些研究,但大多数时间 

I want to show Text and image on the same cell of a datagridview in vb.net, I had done some research but most of the time 

发现在两个单独的列/单元格中添加图像和文本,是否有任何直接的解决方案我可以使用vb.net中的datagridview

found adding image and text in two seperate columns/cells , Is there any straight forward solution i can do this using datagridview in vb.net

推荐答案

也许您可以重载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);
                    }


这篇关于在Datagridview vb.net的同一单元格中添加图像和文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆