从Imagelist中读取图像名称 [英] Read Image Name from Imagelist
本文介绍了从Imagelist中读取图像名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在运行期间从imagelist控件中读取图像名称
请帮助我...
I want to read image name from imagelist control during runtime
Kindly help me...
推荐答案
图像
属性> 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
TheImages
property ofImageList
is of typeImageCollection
and is used to add the images to theImageList
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.
TheSystem.Drawing.Image
class, which is used within theImageList
, does not have aName
property as can be seen here
http://msdn.microsoft.com/en-us/library/system.drawing.image_properties.aspx[^]
Hence, one option is to set theTag
property ofImage
, then read theTag
property of the requiredImage
after retrieving it from theImageList
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.
这篇关于从Imagelist中读取图像名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文