窗体设计器生成的代码 private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.PictureBox pictureBox2;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.PictureBox pictureBox3;
        private System.Windows.Forms.Label label9;
        private System.Windows.Forms.PictureBox pictureBox4;
        private System.Windows.Forms.Label label10;
        private System.Windows.Forms.PictureBox pictureBox5;
        private System.Windows.Forms.Label label11;
        private System.Windows.Forms.PictureBox pictureBox6;
        private System.Windows.Forms.Label label12;
        private System.Windows.Forms.PictureBox pictureBox7;
        private System.Windows.Forms.Label label13;
        private System.Windows.Forms.PictureBox pictureBox8;
        private System.Windows.Forms.Label label14;
        private System.Windows.Forms.PictureBox pictureBox9;
        private System.Windows.Forms.Label label15;
        private System.Windows.Forms.PictureBox pictureBox10;
        private System.Windows.Forms.Label label16;
        private System.Windows.Forms.PictureBox pictureBox11;
        private System.Windows.Forms.Label label17;
        private System.Windows.Forms.Label label18;
        private System.Windows.Forms.Label label19;
        private System.Windows.Forms.Label label20;
        private System.Windows.Forms.Label label21;
        private System.Windows.Forms.PictureBox pictureBox12;
        private System.Windows.Forms.PictureBox pictureBox13;
        private System.Windows.Forms.PictureBox pictureBox14;
        private System.Windows.Forms.PictureBox pictureBox15;
        private System.Windows.Forms.PictureBox pictureBox16;
        private System.Windows.Forms.Label label22;
        private System.Windows.Forms.Label label23;
        private System.Windows.Forms.Label label24;
        private System.Windows.Forms.Label label25;
        private System.Windows.Forms.Label label26;
        private System.Windows.Forms.PictureBox pictureBox17;
        private System.Windows.Forms.PictureBox pictureBox18;
        private System.Windows.Forms.PictureBox pictureBox19;
        private System.Windows.Forms.PictureBox pictureBox20;
        private System.Windows.Forms.PictureBox pictureBox21;
        private System.Windows.Forms.Label label27;
        private System.Windows.Forms.Label label28;
        private System.Windows.Forms.Label label29;
        private System.Windows.Forms.Label label30;
        private System.Windows.Forms.Label label31;
        private System.Windows.Forms.PictureBox pictureBox22;
        private System.Windows.Forms.PictureBox pictureBox23;
        private System.Windows.Forms.PictureBox pictureBox24;
        private System.Windows.Forms.PictureBox pictureBox25;
        private System.Windows.Forms.PictureBox pictureBox26;
        private System.Windows.Forms.Label label1;
示例控件的详情设计情况     // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.BackColor = System.Drawing.Color.Transparent;
            this.label6.Cursor = System.Windows.Forms.Cursors.Hand;
            this.label6.Font = new System.Drawing.Font("宋体", 13F, System.Drawing.FontStyle.Bold);
            this.label6.ForeColor = System.Drawing.Color.White;
            this.label6.Location = new System.Drawing.Point(66, 167);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(76, 18);
            this.label6.TabIndex = 2;
            this.label6.Text = "御   湾";
            this.label6.Click += new System.EventHandler(this.label6_Click);
            // 
            // pictureBox1
            // 
            this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
            this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));
            this.pictureBox1.Location = new System.Drawing.Point(47, 170);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(13, 13);
            this.pictureBox1.TabIndex = 3;
            this.pictureBox1.TabStop = false;界面上有这些控件,运行后发现要加载5秒钟才能把全部控件显示出来,
请问有什么办法能提高下加载速度吗?

解决方案 »

  1.   

    因为我点击每个lable会调用一个VideoShow窗体,是显示一个视频。这样我每次关闭视频后,又会重新加载一次Form1窗体,这次大概3秒左右
      

  2.   

    UI加载太慢了,已经把DoubleBuffered设置为true:对控件就行双缓存处理
      

  3.   

    使用窗体的doublebuffer为true。
    如果达不到你的要求,就不要使用dotnet了,
    这本来就是他的弱项。
      

  4.   

    。我把其他控件都注释,只留三个控件,UI在0.5内完成加载。
    纯粹是界面的控件加载问题,不设计数据读取
    因为这些数据是直接写死,赋值给lable的
      

  5.   

    你的这几十个控件需要5秒钟才能加载完?不会吧?我也做过一个form上五六十个控件的,也就半秒钟啊!是否你的那些picturebox都同时导入了图片??如果先从硬盘读取图片,就可能会几秒钟的时间,否则一定是哪里代码没用对。
      

  6.   

    如果是要花5秒钟的时间,不应该是CPU慢,很可能是从硬盘读取图片文件造成的。如果这样,采用多线程并不对症。
    如果是读图片导致的慢(把所有的读图片的动作去掉,再试试,就能确认),可以“事先把图片读到内存中”来解决。
      

  7.   

    你还是先找找慢在那个步骤上了吧,如果能看到界面大小来回变化,也可以想办法防止其频繁的sizechanged,如果图片加载慢,就在窗体构造同时,使用单独线程加载图片到内存, 然后再调用invoke方式加载图片,这方面的例程很多,上网查查“多线程 窗体操作”就行
      

  8.   

    方法1 异步加载窗体控件
    方法2 把这个窗体单例 (单例后就不要close了,只  show和 hide)
      

  9.   

    发现问题了
    是图片加载太慢 有三十来个图片要加载,图片路径是固定的 不是读取数据库的
    那么就是说要
    如果图片加载慢,就在窗体构造同时,使用单独线程加载图片到内存, 然后再调用invoke方式加载图片,
      

  10.   

    就是
     public Form1()
            {
               //在这里 执行 加载图片到内存么?单独开个线程么?
                InitializeComponent();//这个就是构造窗体
           
            }