浏览代码

添加双缓冲

章政 6 年之前
父节点
当前提交
47335c2c67
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

+ 8 - 0
UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

@@ -14,6 +14,7 @@ using System.Threading;
 using System.IO;
 using System.IO.Ports;
 using UAS_LabelMachine.CustomControl;
+using System.Reflection;
 
 namespace UAS_LabelMachine
 {
@@ -114,7 +115,14 @@ namespace UAS_LabelMachine
 
         public UAS_出货标签打印(string Master)
         {
+            //设置窗体的双缓冲
+            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
+            this.UpdateStyles();
             InitializeComponent();
+            //利用反射设置DataGridView的双缓冲
+            Type dgvType = this.LabelInf.GetType();
+            PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
+            pi.SetValue(this.LabelInf, true, null);
             Text = Text + "-" + Master;
         }