//问题是:动态生成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];
        }

解决方案 »

  1.   

    你建立一个静态类来保存你的ImageList把... 是不是调用频繁了?
      

  2.   


    只有在窗体Load来调用了、没有频繁调用啊!
      

  3.   

    你把你的ImageList放一个静态类里看看把
      

  4.   

    预加载一下吧。.net第一次运行要预编译一下所以会慢
      

  5.   

     private void NewImagelists()
            {            this.Button1.Image = Properties.Resources.DOWN;
            }
    你完全可以这样写。
      

  6.   

    private static 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];
            }
      

  7.   

    对阿,你就给button设个image,直接指定资源文件里的某个图片就ok了
      

  8.   


    //这样会出错:无法将类型“System.Drawing.Icon”隐式转换为“System.Drawing.Image”
      

  9.   


    不是啊!图片仅有几K的小ICO文件。
      

  10.   

                Icon a = Properties.Resources.DOWN;//location can be a string pointing to a file in your hard drive
                Image im = a.ToBitmap();this.Button1.Image =im;
      

  11.   

    //谢谢大大,这样可以,但是窗体打开的有点闪,与Button加载ICO文件有关系,
    //假如不加载ICO文件就正常了。
      

  12.   

    要么这样            this.SuspendLayout();            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];            this.ResumeLayout(false);