你怎么映像文件添加到图像列表中的code? [英] How do you add image file to a image list in code?

查看:266
本文介绍了你怎么映像文件添加到图像列表中的code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图像列表,并希望图像的目录添加到图像列表中的我的code。我将如何做到这一点?当我运行code:

I have an image list and would like to add a directory of images to the image list in my code. How would I do this? When I run the code:

'Load all of the items from the imagelist
For Each path As String In Directory.GetFiles("Images\LanguageIcons\")
     imlLanguagesIcons.Images.Add(Image.FromFile(path))
Next

我得到一个内存溢出异常。目前只有14的图像所以真的不应该是一个问题。任何帮助吗?

I get an out of memory exception. Currently there is only 14 images so there really shouldn't be a problem. Any Help?

推荐答案

像这样

imageList.Images.Add(someImage);

其中, someImage 图片变量。

修改:像这样的:

For Each path As String In Directory.GetFiles("Images\LanguageIcons")
    imageList.Images.Add(Image.FromFile(path))
Next

这篇关于你怎么映像文件添加到图像列表中的code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆