如何使用图像列表控件 [英] How to use imageList Control
问题描述
我有我添加到图像列表Cotrol手动一些图像。 现在我需要删除thart根据关键指标,从图像列表的图像,并设置为面板化背景。
我应该怎么办呢 P>
图片
您在图片列表中添加添加到<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.imagecollection.aspx">ImageList.ImageCollection,所以它是集合类型,那么你可以使用大多数的收集方法。
使用Images属性添加,删除和获取面板的背景中显示的图像。
添加(键,图像)
<一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.imagecollection.remove.aspx">Remove()
<一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.imagecollection.removeat.aspx">RemoveAt()
<一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.imagecollection.removebykey.aspx">RemoveByKey()
请检查<一个例子href="http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist%28v=VS.100%29.aspx">ImageList 类文档,以了解如何务实地使用所有这些方法。
添加图片:
imageList1.Images.Add(PIC1,Image.FromFile(C:\\ mypic.jpg));
从集合删除图片:
imageList1.Images.RemoveAt(listBox1.SelectedIndex);
imageList1.Images..RemoveByKey(PIC1);
要访问图像,从imagecollection获得的图像
panel1.BackgroundImage = imageList1.Images [0];
或
panel1.BackgroundImage = imageList1.Images [PIC1];
I have some images that i added to imageList Cotrol manually. Now i need remove thart images from imageList depending on the key index and set as panel backgroud.
How should i do it
Images
that you added in Image list are added to the ImageList.ImageCollection, so it is collection type then you can use most of the collection methods.
Use the Images property to add, remove and access the image to display in background of panel.
Add(key,image)
Remove()
RemoveAt()
RemoveByKey()
Check the example on the ImageList Class documentation to understand that how pragmatically use all of these methods.
Add Image:
imageList1.Images.Add("pic1", Image.FromFile("c:\\mypic.jpg"));
Remove Image from collection:
imageList1.Images.RemoveAt(listBox1.SelectedIndex);
imageList1.Images..RemoveByKey("pic1");
To access images, get image from the imagecollection
panel1.BackgroundImage = imageList1.Images[0];
or
panel1.BackgroundImage = imageList1.Images["pic1"];
这篇关于如何使用图像列表控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!