回答
Images
添加到ImageList.ImageCollection,所以它是集合类型,那么你可以使用大多数的收集方法。
使用Images属性添加,删除和访问要在面板背景中显示的图像。 Add(key,image)
Remove()
RemoveAt()
RemoveByKey()
检查的ImageList Class文档的例子来理解如何使用务实所有这些方法。
添加图像:从收集
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 [0];但图像没有正确显示,我需要使用其他方法吗? – 2011-12-22 05:19:47
检查面板的图像视图设置的BackgroundImageLayout属性..图像列表可以存储最大256x256像素的图像。 – 2011-12-22 06:52:45
非常感谢,伟大的作品 – 2011-12-22 07:08:47
使用ImageList
控制的Images
property。
它返回的对象ImageList.ImageCollection
提供了处理列表中图像所需的所有方法,包括Add
和Remove
方法。
你可以找到设置Panel
控制这里的背景说明:您在图片列表中所增加How to: Set the Background of a Windows Forms Panel
我尝试使用这种方法,但它返回无效imageList1.Images.RemoveByKey(“nameOfImage”) – 2011-12-21 09:09:03
是的,它应该返回'void'。这是该方法的签名。请参阅[文档](http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.imagecollection.removebykey.aspx)。它不会返回成功或失败。 – 2011-12-21 09:13:40
我在列表视图中使用imagelist。
让我说我在imagelist中有三个图像,并且想要删除它中的两个图像。
我使用的代码
imagelist.Images.RemoveAt(2);
代码被删除第二图象但3图像后机器人虽然可见是有
我的问题是imagelist不是自动刷新 – neerajMAX 2013-02-15 07:22:31
- 1. 如何在我的项目中为所有表单使用一个ImageList控件?
- 2. 如何从资源文件填充ImageList
- 3. 如何获得Magick :: ImageList?
- 4. VB.NET - 使用的DrawImage用的ImageList
- 5. 如何在ImageList中使用半透明图像
- 6. 使用View.Details向ImageList填充ListView
- 7. 无法从Windows服务器2003上的mscomctl.ocx加载控件'imagelist'
- 8. 如何使用RichTextBox控件
- 9. 如何使用RichTextBox控件?
- 10. 如何从ImageList加载透明图像?
- 11. 处理ImageList
- 12. 与imagelist相关
- 13. C#WinForms TreeView&ImageList
- 14. ImageList和BltBit - ting
- 15. ImageList/Image OutOfMemoryException
- 16. ListList中的ImageList
- 17. 如何使用asp.net克隆/复制控件(使用子控件)?
- 18. 如何使用TextBox以外的控件使用Validator控件?
- 19. 如何从较小的组件图像构建C#ImageList图像?
- 20. 如何在一个控件中多次使用用户控件
- 21. 如何使用代码在控件上应用控件资源
- 22. 如何使用Active X控件将.exe插入用户控件
- 23. C#如何获得所需的控制(ImageList中),同时通过Windows窗体
- 24. 如何将HIMAGELIST(来自SetupDiGetClassImageList)用作.NET ImageList?
- 25. ImageList向我保证Alphablending,但是如何启用它?
- 26. .NET ImageList实现中的ImageList容量错误?
- 27. 如何使用其他控件的值更新CGridView控件
- 28. 如何在替代控件中使用ASP.Net服务器控件?
- 29. 如何使用控件源的名称从控件获取值?
- 30. 如何使用Calendar控件的日期填充TextBox控件?
你要根据自己的索引中删除一些图像,并将它们添加的屁股背景你的小组? – Moonlight 2011-12-21 09:05:36
是的你是对的 – 2011-12-21 09:11:26