且构网

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

从Imagelist中读取图像名称

更新时间:2023-12-05 14:52:46

图像 属性> ImageList 的类型为 ImageCollection ,用于添加图像到这里给出的 ImageList

http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.images(v = VS.90 ).aspx [ ^ ]

因此,无法从此系列中获取图像的名称。

System.Drawing.Image 类,在 ImageList 中使用,没有名称此处可以看到属性

http://msdn.microsoft.com/en-us/library/system.drawing.image_properties.aspx [ ^ ]

因此,一个选项是设置标记 图像的属性,然后读取所需的标记属性从 ImageList
The Images property of ImageList is of type ImageCollection and is used to add the images to the ImageList as given here.
http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.images(v=vs.90).aspx[^]
So, as such the name of the image cannot be obtained from this collection.
The System.Drawing.Image class, which is used within the ImageList, does not have a Name property as can be seen here
http://msdn.microsoft.com/en-us/library/system.drawing.image_properties.aspx[^]
Hence, one option is to set the Tag property of Image, then read the Tag property of the required Image after retrieving it from the ImageList


for (int i = 0; i < imageList1.Images.Count; i++)
           {
               listBox1.Items.Add( imageList1.Images.Keys[i].ToString());
           }


Hi Livingstan,





图像列表中的图像没有名称,只有索引。
Hi Livingstan,


Images in an imagelist don't have names they only have an index.