切换界面时界面刷新慢,怎么解决

headgo 2011-04-09 07:05:07
刚接触VC#不久,做了一个界面,上面有个tab,里面放置了3个按键,20个label和20tTextBox,这些空间放置在几个groupBox中进行分组。程序才刚刚进行界面设计,没有其他操作。发现在本程序内部从其他tab页切换到这个tab页时,甚至从其他程序切换到本程序时,这个界面刷新比较慢,能明显看到控件重画的过程。

目前主流机器,所以不应该是机器慢的问题。

也听说过双缓存,在界面构造函数中调用如下代码也不起作用:
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

刷新慢尽管不影响程序使用功能,但给使用者的体验肯定不好,所以希望解决这个问题,请大家赐教。
...全文
819 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
headgo 2011-05-09
  • 打赏
  • 举报
回复
是在没办法,只好自己习惯了。
有人说WPF更慢,不知是不是真的?
headgo 2011-04-11
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 xxiju203 的回复:]

GDI的性能本来就不高,你也可以测试用WPF来开发你的应用。
[/Quote]

偶用的是VS2005,.net 2.0。WPF是.net3.0的容。现在VS2005是不是太落后了。
haiandj 2011-04-11
  • 打赏
  • 举报
回复
做成渐入渐出吧,这没办法
xxiju203 2011-04-11
  • 打赏
  • 举报
回复
GDI的性能本来就不高,你也可以测试用WPF来开发你的应用。
xxiju203 2011-04-11
  • 打赏
  • 举报
回复
同一个界面上的控件太多了 winForm就是这样的 尝试重新布局控件,比如做做分组,放在不同的TabControl页中。
headgo 2011-04-11
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 colinmelody 的回复:]

能明显看出画控件的步骤?

估计真是电脑硬件问题。~
[/Quote]

可能描述有些夸张,但能明显感觉到闪烁是确实的,机子是主流机器。
ColinMelody 2011-04-11
  • 打赏
  • 举报
回复
能明显看出画控件的步骤?

估计真是电脑硬件问题。~
headgo 2011-04-11
  • 打赏
  • 举报
回复
文件MainForm.Designer.cs续:


//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(521, 51);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(56, 14);
this.label9.TabIndex = 14;
this.label9.Text = "风机3:";
//
// textBox9
//
this.textBox9.Location = new System.Drawing.Point(604, 48);
this.textBox9.Name = "textBox9";
this.textBox9.ReadOnly = true;
this.textBox9.Size = new System.Drawing.Size(100, 23);
this.textBox9.TabIndex = 5;
this.textBox9.Text = "模式1";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(94, 48);
this.textBox4.Name = "textBox4";
this.textBox4.ReadOnly = true;
this.textBox4.Size = new System.Drawing.Size(100, 23);
this.textBox4.TabIndex = 3;
this.textBox4.Text = "除尘运行";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(349, 19);
this.textBox5.Name = "textBox5";
this.textBox5.ReadOnly = true;
this.textBox5.Size = new System.Drawing.Size(100, 23);
this.textBox5.TabIndex = 1;
this.textBox5.Text = "加电";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(94, 19);
this.textBox6.Name = "textBox6";
this.textBox6.ReadOnly = true;
this.textBox6.Size = new System.Drawing.Size(100, 23);
this.textBox6.TabIndex = 0;
this.textBox6.Text = "已自检";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(268, 54);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(56, 14);
this.label7.TabIndex = 18;
this.label7.Text = "风机2:";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(521, 22);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(77, 14);
this.label8.TabIndex = 16;
this.label8.Text = "电辅加热:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(11, 51);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 14);
this.label4.TabIndex = 12;
this.label4.Text = "风机1:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(266, 22);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(77, 14);
this.label5.TabIndex = 10;
this.label5.Text = "上电状态:";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(11, 22);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(77, 14);
this.label6.TabIndex = 8;
this.label6.Text = "自检状态:";
//
// tabPage3
//
this.tabPage3.Location = new System.Drawing.Point(4, 23);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
this.tabPage3.Size = new System.Drawing.Size(786, 481);
this.tabPage3.TabIndex = 0;
this.tabPage3.Text = "参数设置信息";
this.tabPage3.UseVisualStyleBackColor = true;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1016, 734);
this.Controls.Add(this.tabSetting);
this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "电源监控";
this.Load += new System.EventHandler(this.MainForm_Load);
this.tabSetting.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox5.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.TextBox textBox39;
private System.Windows.Forms.TextBox textBox40;
private System.Windows.Forms.TextBox textBox41;
private System.Windows.Forms.TextBox textBox42;
private System.Windows.Forms.Label label39;
private System.Windows.Forms.Label label40;
private System.Windows.Forms.Label label41;
private System.Windows.Forms.Label label42;
private System.Windows.Forms.TabControl tabSetting;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TextBox textBox11;
private System.Windows.Forms.TextBox textBox12;
private System.Windows.Forms.TextBox textBox16;
private System.Windows.Forms.TextBox textBox17;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.Button btnCmdStop;
private System.Windows.Forms.Button btnCmdStart;
private System.Windows.Forms.Button btnCmdCheck;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.TextBox textBox18;
private System.Windows.Forms.TextBox textBox19;
private System.Windows.Forms.TextBox textBox20;
private System.Windows.Forms.TextBox textBox21;
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.GroupBox groupBox2;
private System.Windows.Forms.TextBox textBox10;
private System.Windows.Forms.TextBox textBox13;
private System.Windows.Forms.TextBox textBox14;
private System.Windows.Forms.TextBox textBox15;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBox7;
private System.Windows.Forms.TextBox textBox8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox textBox9;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TabPage tabPage3;
}
}



论坛有没有上传附件的功能?
在回复里上传代码太麻烦了,稍微复杂点的界面就超过10000字符了,再加上只能连续3次回复的限制,上传代码好麻烦啊。
headgo 2011-04-11
  • 打赏
  • 举报
回复
谢谢各位,受限于论坛只能连续发3个回复,代码没有发完全。今天继续。
另外要强调一下的是,界面构造函数和Load函数中可以说几乎没有自己写的代码,别的地方也没有代码,可以说就是一个原始的界面设计。但在进行程序切换或tab切换时能明显感觉到闪烁。

文件MainForm.Designer.cs续:
 

this.btnCmdCheck.Location = new System.Drawing.Point(94, 18);
this.btnCmdCheck.Name = "btnCmdCheck";
this.btnCmdCheck.Size = new System.Drawing.Size(100, 23);
this.btnCmdCheck.TabIndex = 0;
this.btnCmdCheck.Text = "自检";
this.btnCmdCheck.UseVisualStyleBackColor = true;

this.groupBox4.Controls.Add(this.textBox18);
this.groupBox4.Controls.Add(this.textBox19);
this.groupBox4.Controls.Add(this.textBox20);
this.groupBox4.Controls.Add(this.textBox21);
this.groupBox4.Controls.Add(this.label18);
this.groupBox4.Controls.Add(this.label19);
this.groupBox4.Controls.Add(this.label20);
this.groupBox4.Controls.Add(this.label21);
this.groupBox4.Location = new System.Drawing.Point(11, 373);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(730, 75);
this.groupBox4.TabIndex = 5;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "温湿度";

this.textBox18.Location = new System.Drawing.Point(538, 44);
this.textBox18.Name = "textBox18";
this.textBox18.ReadOnly = true;
this.textBox18.Size = new System.Drawing.Size(100, 23);
this.textBox18.TabIndex = 3;
this.textBox18.Text = "除尘运行";

this.textBox19.Location = new System.Drawing.Point(107, 44);
this.textBox19.Name = "textBox19";
this.textBox19.ReadOnly = true;
this.textBox19.Size = new System.Drawing.Size(100, 23);
this.textBox19.TabIndex = 2;
this.textBox19.Text = "除尘运行";

this.textBox20.Location = new System.Drawing.Point(538, 16);
this.textBox20.Name = "textBox20";
this.textBox20.ReadOnly = true;
this.textBox20.Size = new System.Drawing.Size(100, 23);
this.textBox20.TabIndex = 1;
this.textBox20.Text = "连续";

this.textBox21.Location = new System.Drawing.Point(107, 16);
this.textBox21.Name = "textBox21";
this.textBox21.ReadOnly = true;
this.textBox21.Size = new System.Drawing.Size(100, 23);
this.textBox21.TabIndex = 0;
this.textBox21.Text = "模式1";

this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(11, 19);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(105, 14);
this.label18.TabIndex = 8;
this.label18.Text = "输出电压(kV):";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(418, 47);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(126, 14);
this.label19.TabIndex = 16;
this.label19.Text = "电流密度(uA/m2):";

this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(418, 19);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(105, 14);
this.label20.TabIndex = 10;
this.label20.Text = "输出电流(mA):";

this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(11, 47);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(98, 14);
this.label21.TabIndex = 12;
this.label21.Text = "火化率(spm):";

this.groupBox2.Controls.Add(this.textBox10);
this.groupBox2.Controls.Add(this.textBox13);
this.groupBox2.Controls.Add(this.textBox14);
this.groupBox2.Controls.Add(this.textBox15);
this.groupBox2.Controls.Add(this.label15);
this.groupBox2.Controls.Add(this.label11);
this.groupBox2.Controls.Add(this.label14);
this.groupBox2.Controls.Add(this.label13);
this.groupBox2.Location = new System.Drawing.Point(11, 201);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(730, 80);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "高压侧";
//
// textBox10
//
this.textBox10.Location = new System.Drawing.Point(538, 48);
this.textBox10.Name = "textBox10";
this.textBox10.ReadOnly = true;
this.textBox10.Size = new System.Drawing.Size(100, 23);
this.textBox10.TabIndex = 3;
this.textBox10.Text = "除尘运行";

this.textBox13.Location = new System.Drawing.Point(107, 45);
this.textBox13.Name = "textBox13";
this.textBox13.ReadOnly = true;
this.textBox13.Size = new System.Drawing.Size(100, 23);
this.textBox13.TabIndex = 2;
this.textBox13.Text = "除尘运行";

this.textBox14.Location = new System.Drawing.Point(538, 16);
this.textBox14.Name = "textBox14";
this.textBox14.ReadOnly = true;
this.textBox14.Size = new System.Drawing.Size(100, 23);
this.textBox14.TabIndex = 1;
this.textBox14.Text = "连续";

this.textBox15.Location = new System.Drawing.Point(107, 16);
this.textBox15.Name = "textBox15";
this.textBox15.ReadOnly = true;
this.textBox15.Size = new System.Drawing.Size(100, 23);
this.textBox15.TabIndex = 0;
this.textBox15.Text = "模式1";
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(11, 19);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(105, 14);
this.label15.TabIndex = 8;
this.label15.Text = "输出电压(kV):";

this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(418, 51);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(126, 14);
this.label11.TabIndex = 16;
this.label11.Text = "电流密度(uA/m2):";

this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(418, 19);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(105, 14);
this.label14.TabIndex = 10;
this.label14.Text = "输出电流(mA):";

this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(11, 48);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(98, 14);
this.label13.TabIndex = 12;
this.label13.Text = "火化率(spm):";

this.groupBox1.Controls.Add(this.textBox7);
this.groupBox1.Controls.Add(this.textBox8);
this.groupBox1.Controls.Add(this.label9);
this.groupBox1.Controls.Add(this.textBox9);
this.groupBox1.Controls.Add(this.textBox4);
this.groupBox1.Controls.Add(this.textBox5);
this.groupBox1.Controls.Add(this.textBox6);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Location = new System.Drawing.Point(11, 118);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(730, 77);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "工作状态";
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(349, 48);
this.textBox7.Name = "textBox7";
this.textBox7.ReadOnly = true;
this.textBox7.Size = new System.Drawing.Size(100, 23);
this.textBox7.TabIndex = 4;
this.textBox7.Text = "除尘运行";
//
// textBox8
//
this.textBox8.Location = new System.Drawing.Point(604, 19);
this.textBox8.Name = "textBox8";
this.textBox8.ReadOnly = true;
this.textBox8.Size = new System.Drawing.Size(100, 23);
this.textBox8.TabIndex = 2;
this.textBox8.Text = "连续";
拿凤姐抵债 2011-04-11
  • 打赏
  • 举报
回复
逐步添加功能。
拿凤姐抵债 2011-04-11
  • 打赏
  • 举报
回复
首先把业务都去掉。看一看速度。
就是frm_Load或者其他内容的都注释掉,一步一步看哪里问题。
xxiju203 2011-04-11
  • 打赏
  • 举报
回复
上WPF吧 会有所改观的
huwei001982 2011-04-11
  • 打赏
  • 举报
回复
winform 的特点, 如果你一定要在同一个窗体上放这么多控件,那估计没什么好办法解决
headgo 2011-04-10
  • 打赏
  • 举报
回复
文件MainForm.Designer.cs续:

//
// tabSetting
//
this.tabSetting.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabSetting.Controls.Add(this.tabPage1);
this.tabSetting.Controls.Add(this.tabPage3);
this.tabSetting.Location = new System.Drawing.Point(3, 12);
this.tabSetting.Name = "tabSetting";
this.tabSetting.SelectedIndex = 0;
this.tabSetting.Size = new System.Drawing.Size(1001, 689);
this.tabSetting.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.AutoScroll = true;
this.tabPage1.Controls.Add(this.groupBox6);
this.tabPage1.Controls.Add(this.groupBox3);
this.tabPage1.Controls.Add(this.groupBox5);
this.tabPage1.Controls.Add(this.groupBox4);
this.tabPage1.Controls.Add(this.groupBox2);
this.tabPage1.Controls.Add(this.groupBox1);
this.tabPage1.Location = new System.Drawing.Point(4, 23);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(993, 662);
this.tabPage1.TabIndex = 2;
this.tabPage1.Text = "详细运行信息";
this.tabPage1.UseVisualStyleBackColor = true;
//
// groupBox6
//
this.groupBox6.Controls.Add(this.label1);
this.groupBox6.Controls.Add(this.textBox1);
this.groupBox6.Controls.Add(this.textBox2);
this.groupBox6.Controls.Add(this.label2);
this.groupBox6.Controls.Add(this.textBox3);
this.groupBox6.Controls.Add(this.label3);
this.groupBox6.Location = new System.Drawing.Point(11, 11);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(730, 47);
this.groupBox6.TabIndex = 0;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "基本";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(11, 19);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(77, 14);
this.label1.TabIndex = 2;
this.label1.Text = "运行模式:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(94, 16);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(100, 23);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "模式1";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(349, 16);
this.textBox2.Name = "textBox2";
this.textBox2.ReadOnly = true;
this.textBox2.Size = new System.Drawing.Size(100, 23);
this.textBox2.TabIndex = 1;
this.textBox2.Text = "连续";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(266, 19);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(77, 14);
this.label2.TabIndex = 4;
this.label2.Text = "运行方式:";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(604, 16);
this.textBox3.Name = "textBox3";
this.textBox3.ReadOnly = true;
this.textBox3.Size = new System.Drawing.Size(100, 23);
this.textBox3.TabIndex = 2;
this.textBox3.Text = "除尘运行";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(521, 19);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(77, 14);
this.label3.TabIndex = 6;
this.label3.Text = "工作过程:";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.textBox11);
this.groupBox3.Controls.Add(this.textBox12);
this.groupBox3.Controls.Add(this.textBox16);
this.groupBox3.Controls.Add(this.textBox17);
this.groupBox3.Controls.Add(this.label10);
this.groupBox3.Controls.Add(this.label12);
this.groupBox3.Controls.Add(this.label16);
this.groupBox3.Controls.Add(this.label17);
this.groupBox3.Location = new System.Drawing.Point(11, 287);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(730, 80);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "低压侧";
//
// textBox11
//
this.textBox11.Location = new System.Drawing.Point(538, 48);
this.textBox11.Name = "textBox11";
this.textBox11.ReadOnly = true;
this.textBox11.Size = new System.Drawing.Size(100, 23);
this.textBox11.TabIndex = 3;
this.textBox11.Text = "除尘运行";
//
// textBox12
//
this.textBox12.Location = new System.Drawing.Point(107, 45);
this.textBox12.Name = "textBox12";
this.textBox12.ReadOnly = true;
this.textBox12.Size = new System.Drawing.Size(100, 23);
this.textBox12.TabIndex = 2;
this.textBox12.Text = "除尘运行";
//
// textBox16
//
this.textBox16.Location = new System.Drawing.Point(538, 16);
this.textBox16.Name = "textBox16";
this.textBox16.ReadOnly = true;
this.textBox16.Size = new System.Drawing.Size(100, 23);
this.textBox16.TabIndex = 1;
this.textBox16.Text = "连续";
//
// textBox17
//
this.textBox17.Location = new System.Drawing.Point(107, 16);
this.textBox17.Name = "textBox17";
this.textBox17.ReadOnly = true;
this.textBox17.Size = new System.Drawing.Size(100, 23);
this.textBox17.TabIndex = 0;
this.textBox17.Text = "模式1";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(11, 19);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(105, 14);
this.label10.TabIndex = 8;
this.label10.Text = "输出电压(kV):";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(418, 51);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(126, 14);
this.label12.TabIndex = 16;
this.label12.Text = "电流密度(uA/m2):";
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(418, 19);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(105, 14);
this.label16.TabIndex = 10;
this.label16.Text = "输出电流(mA):";
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(11, 48);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(98, 14);
this.label17.TabIndex = 12;
this.label17.Text = "火化率(spm):";
//
// groupBox5
//
this.groupBox5.Controls.Add(this.btnCmdStop);
this.groupBox5.Controls.Add(this.btnCmdStart);
this.groupBox5.Controls.Add(this.btnCmdCheck);
this.groupBox5.Location = new System.Drawing.Point(11, 65);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(730, 47);
this.groupBox5.TabIndex = 1;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "操作";
//
// btnCmdStop
//
this.btnCmdStop.Location = new System.Drawing.Point(604, 18);
this.btnCmdStop.Name = "btnCmdStop";
this.btnCmdStop.Size = new System.Drawing.Size(100, 23);
this.btnCmdStop.TabIndex = 2;
this.btnCmdStop.Text = "停止";
this.btnCmdStop.UseVisualStyleBackColor = true;
//
// btnCmdStart
//
this.btnCmdStart.Location = new System.Drawing.Point(349, 18);
this.btnCmdStart.Name = "btnCmdStart";
this.btnCmdStart.Size = new System.Drawing.Size(100, 23);
this.btnCmdStart.TabIndex = 1;
this.btnCmdStart.Text = "启动";
this.btnCmdStart.UseVisualStyleBackColor = true;
headgo 2011-04-10
  • 打赏
  • 举报
回复
文件MainForm.Designer.cs:

namespace HMI
{
partial class MainForm
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows 窗体设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox39 = new System.Windows.Forms.TextBox();
this.textBox40 = new System.Windows.Forms.TextBox();
this.textBox41 = new System.Windows.Forms.TextBox();
this.textBox42 = new System.Windows.Forms.TextBox();
this.label39 = new System.Windows.Forms.Label();
this.label40 = new System.Windows.Forms.Label();
this.label41 = new System.Windows.Forms.Label();
this.label42 = new System.Windows.Forms.Label();
this.tabSetting = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.textBox11 = new System.Windows.Forms.TextBox();
this.textBox12 = new System.Windows.Forms.TextBox();
this.textBox16 = new System.Windows.Forms.TextBox();
this.textBox17 = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.btnCmdStop = new System.Windows.Forms.Button();
this.btnCmdStart = new System.Windows.Forms.Button();
this.btnCmdCheck = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.textBox18 = new System.Windows.Forms.TextBox();
this.textBox19 = new System.Windows.Forms.TextBox();
this.textBox20 = new System.Windows.Forms.TextBox();
this.textBox21 = new System.Windows.Forms.TextBox();
this.label18 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label20 = new System.Windows.Forms.Label();
this.label21 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.textBox10 = new System.Windows.Forms.TextBox();
this.textBox13 = new System.Windows.Forms.TextBox();
this.textBox14 = new System.Windows.Forms.TextBox();
this.textBox15 = new System.Windows.Forms.TextBox();
this.label15 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.textBox7 = new System.Windows.Forms.TextBox();
this.textBox8 = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.textBox9 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.textBox6 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.tabSetting.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox6.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// textBox39
//
this.textBox39.Location = new System.Drawing.Point(538, 44);
this.textBox39.Name = "textBox39";
this.textBox39.ReadOnly = true;
this.textBox39.Size = new System.Drawing.Size(100, 21);
this.textBox39.TabIndex = 3;
this.textBox39.Text = "除尘运行";
//
// textBox40
//
this.textBox40.Location = new System.Drawing.Point(107, 44);
this.textBox40.Name = "textBox40";
this.textBox40.ReadOnly = true;
this.textBox40.Size = new System.Drawing.Size(100, 21);
this.textBox40.TabIndex = 2;
this.textBox40.Text = "除尘运行";
//
// textBox41
//
this.textBox41.Location = new System.Drawing.Point(538, 16);
this.textBox41.Name = "textBox41";
this.textBox41.ReadOnly = true;
this.textBox41.Size = new System.Drawing.Size(100, 21);
this.textBox41.TabIndex = 1;
this.textBox41.Text = "连续";
//
// textBox42
//
this.textBox42.Location = new System.Drawing.Point(107, 16);
this.textBox42.Name = "textBox42";
this.textBox42.ReadOnly = true;
this.textBox42.Size = new System.Drawing.Size(100, 21);
this.textBox42.TabIndex = 0;
this.textBox42.Text = "模式1";
//
// label39
//
this.label39.AutoSize = true;
this.label39.Location = new System.Drawing.Point(11, 19);
this.label39.Name = "label39";
this.label39.Size = new System.Drawing.Size(89, 12);
this.label39.TabIndex = 8;
this.label39.Text = "输出电压(kV):";
//
// label40
//
this.label40.AutoSize = true;
this.label40.Location = new System.Drawing.Point(418, 47);
this.label40.Name = "label40";
this.label40.Size = new System.Drawing.Size(107, 12);
this.label40.TabIndex = 16;
this.label40.Text = "电流密度(uA/m2):";
//
// label41
//
this.label41.AutoSize = true;
this.label41.Location = new System.Drawing.Point(418, 19);
this.label41.Name = "label41";
this.label41.Size = new System.Drawing.Size(89, 12);
this.label41.TabIndex = 10;
this.label41.Text = "输出电流(mA):";
//
// label42
//
this.label42.AutoSize = true;
this.label42.Location = new System.Drawing.Point(11, 47);
this.label42.Name = "label42";
this.label42.Size = new System.Drawing.Size(83, 12);
this.label42.TabIndex = 12;
this.label42.Text = "火化率(spm):";
headgo 2011-04-10
  • 打赏
  • 举报
回复
程序已经被我简化成最简单了,只有三个文件,出了设置双缓存代码以外,没有任何自写的代码了:
Program.cs文件:

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace HMI
{
static class Program
{

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}

}
}


文件MainForm.cs:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;


namespace HMI
{
public partial class MainForm : Form
{

public MainForm()
{
InitializeComponent();


#region 设置双缓存,解决闪烁问题
//Type type = tabPage1.GetType();
//PropertyInfo pi = type.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
//pi.SetValue(tabPage1, true, null);

this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);// 设置双缓冲,防止图像抖动,忽略系统消息,防止图像闪烁
#endregion
}

private void MainForm_Load(object sender, EventArgs e)
{

}

private void MenuItemExit_Click(object sender, EventArgs e)
{
this.Close();
}

}
}


ningweidong 2011-04-09
  • 打赏
  • 举报
回复
我觉得有可能是系统的问题,没听说过切换个tab,还卡的。
你放到另一台电脑上看看还卡不卡
余山水 2011-04-09
  • 打赏
  • 举报
回复
load事件和构造方法检查一下,估计是程序问题,我们用过4个tab的也不慢
lulianqi 2011-04-09
  • 打赏
  • 举报
回复
没有这么夸张吧 记得以前 老师要我们做俄罗斯方块 界面就是20×8的 控件组合 有没有什么闪耀啊
headgo 2011-04-09
  • 打赏
  • 举报
回复
没有处理Paint事件。
加载更多回复(1)

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧