C#中imageList动态添加图片问题

C#中imageList动态添加控件中的图片怎么添加啊!这样给你说吧,我是获取程序的图标,有很多,我获取出来保存在PIC控件里的,我要把这些图标保存进IMAGELIST里... C#中imageList动态添加控件中的图片怎么添加啊!
这样给你说吧,我是获取程序的图标,有很多,我获取出来保存在PIC控件里的,我要把这些图标保存进IMAGELIST里,关文件路径什么事啊,不会在把控件里的图片保存文件在添加进去吧,这样麻烦有浪费内存,·

这样会出错,
值不能为空。
参数名: value
要不我不用来问了`。
展开
 我来答
haruno2005
推荐于2017-06-09 · 超过36用户采纳过TA的回答
知道小有建树答主
回答量:97
采纳率:0%
帮助的人:109万
展开全部
不会将favicon.ico换成favicon.jpg或favicon.bmp啊…………
将其它PICBOX控件里的图片路径取出存入imageList即可。

msdn中的实例:
C# 复制代码
internal System.Windows.Forms.ImageList ImageList1;

// Create an ImageList Object, populate it, and display
// the images it contains.
private void Button1_Click(System.Object sender,
System.EventArgs e)
{

// Construct the ImageList.
ImageList1 = new ImageList();

// Set the ImageSize property to a larger size
// (the default is 16 x 16).
ImageList1.ImageSize = new Size(112, 112);

// Add two images to the list.
ImageList1.Images.Add(
Image.FromFile("c:\\windows\\FeatherTexture.bmp"));
ImageList1.Images.Add(
Image.FromFile("C:\\windows\\Gone Fishing.bmp"));

// Get a Graphics object from the form's handle.
Graphics theGraphics = Graphics.FromHwnd(this.Handle);

// Loop through the images in the list, drawing each image.
for(int count = 0; count < ImageList1.Images.Count; count++)
{
ImageList1.Draw(theGraphics, new Point(85, 85), count);

// Call Application.DoEvents to force a repaint of the form.
Application.DoEvents();

// Call the Sleep method to allow the user to see the image.
System.Threading.Thread.Sleep(1000);
}
}

明白吗?难道你会认为imageList.Images.Add()是把地址中的图片存放在imageList中???

增加:
ImageList imageList = new ImageList();
imageList.Images.Add(Image.FromFile(@"D:\我的文件\myrice\favicon.ico"));
imageList.Images.Add(Image.FromFile(@"D:\我的文件\myrice\favicon4.ico"));
imageList.Images.Add(Image.FromFile(@"D:\我的文件\myrice\favicon5.ico"));
读取一
this.lb = new GListBox();
lb.ImageList = imageList;
读取二
imageList.Images[a],括号内为索引,表示你要取的序号,不得超过imageList.Images.count的数量,不然会报错。

为什么不去看msdn??
skyrickie
2008-12-09 · TA获得超过201个赞
知道答主
回答量:303
采纳率:0%
帮助的人:127万
展开全部
imageList1.Images.Add(pictureBox1.Image);
这句话就可以添加进去了!!!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式