如何使用图像列表控件如何使用、控件、图像、列表

由网友(青朷)分享简介:我有我添加到图像列表Cotrol手动一些图像。现在我需要删除thart根据关键指标,从图像列表的图像,并设置为面板化背景。我应该怎么办呢解决方案 图片您在图片列表中添加添加到ImageList.ImageCollection,所以它是集合类型,那么你可以使用大多数的收集方法。 使用Images属性添加,删除和获取...

我有我添加到图像列表Cotrol手动一些图像。 现在我需要删除thart根据关键指标,从图像列表的图像,并设置为面板化背景。

我应该

怎么办呢 解决方案

图片您在图片列表中添加添加到ImageList.ImageCollection,所以它是集合类型,那么你可以使用大多数的收集方法。

使用Images属性添加,删除和获取面板的背景中显示的图像。 添加(键,图像) Remove() RemoveAt() RemoveByKey()

请检查ImageList 类文档,以了解如何务实地使用所有这些方法。

添加图片:

  imageList1.Images.Add(PIC1,Image.FromFile(C: mypic.jpg));
 
MFC 中,按钮和其他 比如 图片框 列表框 控件怎么响应鼠标移动消息

从集合删除图片:

  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"];

阅读全文

相关推荐

最新文章