diff --git a/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs b/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs index c462dd7..021d6e9 100644 --- a/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs +++ b/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs @@ -454,9 +454,9 @@ // // flowLayoutPanel2 // - this.flowLayoutPanel2.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.flowLayoutPanel2.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.flowLayoutPanel2.AutoScroll = true; this.flowLayoutPanel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.flowLayoutPanel2.Location = new System.Drawing.Point(-1, 89); @@ -467,8 +467,9 @@ // // flowLayoutPanel1 // - this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.flowLayoutPanel1.AutoScroll = true; + this.flowLayoutPanel1.WrapContents = true; // 关键:禁止换行,横向滚动 this.flowLayoutPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 4); this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(4); diff --git a/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs b/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs index 3577f4b..1c1691a 100644 --- a/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs +++ b/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs @@ -59,6 +59,8 @@ namespace ButcherFactory.SegmentProductionAuto_ netStateWatch1.GetConnectState = () => LoginUtil.TestConnection(500); this.FormClosing += SegmentProductionAutoForm_FormClosing; this.Load += Form1_Load; + this.Resize += SegmentProductionAutoForm_Resize; // 新增Resize事件 + workUnitSelect.SelectedIndexChanged += delegate { if (workUnitSelect.SelectedValue == null) @@ -91,14 +93,26 @@ namespace ButcherFactory.SegmentProductionAuto_ }; } + // 窗体大小变化时,刷新flowlayout布局,保证滚动区域生效 + private void SegmentProductionAutoForm_Resize(object sender, EventArgs e) + { + if (_isFormClosing || this.IsDisposed) return; + + // 强制刷新布局,解决低分辨率下FlowLayoutPanel不重绘、滚动失效 + flowLayoutPanel1.PerformLayout(); + flowLayoutPanel2.PerformLayout(); + flowLayoutPanel3.PerformLayout(); + flowLayoutPanel4.PerformLayout(); + } + private void Form1_Load(object sender, EventArgs e) { Rectangle workArea = Screen.PrimaryScreen.WorkingArea; - // 取屏幕可用区域的82%,上限限制 1440, 810 - int initW = Math.Min((int)(workArea.Width * 0.9), 1440); - int initH = Math.Min((int)(workArea.Height * 0.9), 810); + // 初始窗口使用屏幕工作区,不再上限死1440,810 + int initW = (int)(workArea.Width * 0.95); + int initH = (int)(workArea.Height * 0.95); this.ClientSize = new Size(initW, initH); - this.MinimumSize = new Size(1000, 650); + this.MinimumSize = new Size(1024, 680); // 设置最小窗口,防止缩太小布局乱掉 }