//问题是:动态生成ImageList后,再让ImageList读资源文件,然后在Login_Load中调用,
//不知道为什么打开窗体有点缓慢的感觉,就是窗体在出现时卡卡的。求助下:是否这样做有问题啊?
private void NewImagelists()
{
ImageList ImageList = new ImageList();
ImageList.ImageSize = new Size(16,16);
ImageList.TransparentColor = Color.White;
ImageList.Images.Add(global::实例.Properties.Resources.UP);
ImageList.Images.Add(global::实例.Properties.Resources.DOWN);
this.Button1.ImageList = ImageList;
this.Button1.Image = ImageList.Images[1];
}
只有在窗体Load来调用了、没有频繁调用啊!
{ this.Button1.Image = Properties.Resources.DOWN;
}
你完全可以这样写。
{
ImageList ImageList = new ImageList();
ImageList.ImageSize = new Size(16,16);
ImageList.TransparentColor = Color.White;
ImageList.Images.Add(global::实例.Properties.Resources.UP);
ImageList.Images.Add(global::实例.Properties.Resources.DOWN);
this.Button1.ImageList = ImageList;
this.Button1.Image = ImageList.Images[1];
}
//这样会出错:无法将类型“System.Drawing.Icon”隐式转换为“System.Drawing.Image”
不是啊!图片仅有几K的小ICO文件。
Image im = a.ToBitmap();this.Button1.Image =im;
//假如不加载ICO文件就正常了。
ImageList.ImageSize = new Size(16,16);
ImageList.TransparentColor = Color.White;
ImageList.Images.Add(global::实例.Properties.Resources.UP);
ImageList.Images.Add(global::实例.Properties.Resources.DOWN);
this.Button1.ImageList = ImageList;
this.Button1.Image = ImageList.Images[1]; this.ResumeLayout(false);