瀏覽代碼

执行过程查询 更改label绘制位置

shim 8 年之前
父節點
當前提交
170e173c24
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      UAS-MES/FunctionCode/Query/Query_ExeProgress.cs

+ 9 - 1
UAS-MES/FunctionCode/Query/Query_ExeProgress.cs

@@ -180,9 +180,17 @@ namespace UAS_MES.Query
                         Param.Text = j + " " + Step[j];
                         Param.Text = j + " " + Step[j];
                         Param.Name = j + Step[j] + "_label";
                         Param.Name = j + Step[j] + "_label";
                         Param.AutoSize = true;
                         Param.AutoSize = true;
+                        Param.Margin = new Padding(0,0,0,0);
                         Param.Anchor = AnchorStyles.Left;
                         Param.Anchor = AnchorStyles.Left;
                         Param.Anchor = AnchorStyles.Top;
                         Param.Anchor = AnchorStyles.Top;
-                        Param.Location = new Point(x + r.Width / 14 * RectangleCountEachRow, y + r.Height / 10 * 4);
+                        //获取param的宽度和高度
+                        Graphics graphics = Graphics.FromHwnd(Param.Handle);
+                        SizeF size = graphics.MeasureString(Param.Text,Param.Font);
+                        
+                        //设定param文本框的位置
+                        //Param.Location = new Point(x + r.Width / 14 * RectangleCountEachRow, y + r.Height / 10 * 4);
+                        Param.Location = new Point(x+(int)(r.Width-size.Width)/2,y+(int)(r.Height-size.Height)/2);
+                        graphics.Dispose();
                         //如果在奇数行
                         //如果在奇数行
                         if (i % 2 != 0)
                         if (i % 2 != 0)
                         {
                         {