DataGridViewImage单元格中的多个图像 [英] Multiple Images in a DataGridViewImage Cell

查看:70
本文介绍了DataGridViewImage单元格中的多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datagridview,用户可以右键单击行上的特定单元格,为记录设置多个属性/类别,就像您可以在Microsoft Outlook的类别列中设置多个类别一样。基本上标记他们。我的所有图像都在图像列表中。我可以在列中获得第一个图像,但是我希望能够将多个图像并排放在这个列中(多个颜色框,如Microsoft Outlook中没有文本)。 DataGridViewImageColumn是否具备此功能?



我尝试过添加多张图片而没有任何运气:

I have a datagridview in which users can right click a particular cell on a row to set multiple attributes/categories to the record, much like you can set multiple categories from the "Categories" column in Microsoft Outlook. Basically flagging them. All of my images are in an image list. I can get the first image in the column, however I would like to be able to put multiple images in this column side by side (multiple color boxes like in Microsoft Outlook only without the text). Does the DataGridViewImageColumn have this ability?

I've tried adding multiple images as such without any luck:

Me.dgv1.CurrentRow.Cells("flagImage").Value = Me.dgv1.CurrentRow.Cells("flagImage").Value & imageList1.Images(1)





以上代码的错误是:

Microsoft.VisualBasic.dll中发生了'System.InvalidCastException'类型的未处理异常

附加信息:运算符'&'未定义类型'位图'并输入'位图'。




我也试过+代替&



感谢您提供的任何帮助。



Error from the above code is:
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Operator '&' is not defined for type 'Bitmap' and type 'Bitmap'.


I've also tried "+" instead of "&"

Thanks for any help provided.

推荐答案

您至少有两种可能性:1)创建自己的列和从 System.Windows.Forms.DataGridViewColumn System.Windows.Forms.DataGridViewCell ,或2)提出了几个方面 - 在 System.Windows.Forms.DataGridViewCell 的实例上显示的单个图像上的侧面图像,并将图像组合并分割成较小的图像。我也会认真地建议你用几个侧面图像审查你的设计;我几乎无法想象他们怎么可能看起来很好。至少要考虑一下。



-SA
You have at least two possibilities: 1) create your own column and cell types derived from System.Windows.Forms.DataGridViewColumn and System.Windows.Forms.DataGridViewCell, or 2) present several side-to-side images on one single image shown on an instance of the System.Windows.Forms.DataGridViewCell and compose and split images into smaller ones. I would also seriously advice your to review your design with several side-to-side images; I hardly can imagine how could they possibly look good. At least just think about it.

—SA


这篇关于DataGridViewImage单元格中的多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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