不会将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??
温馨提示:内容为网友见解,仅供参考