From 108096f905583e45db91e15fac711e49dfbd90a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=93=9D=E7=82=B9lilac?= Date: Sun, 20 Dec 2020 00:44:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B1=85=E4=B8=AD=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BulePointLilac.Controls/MyListBox.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ContextMenuManager/BulePointLilac.Controls/MyListBox.cs b/ContextMenuManager/BulePointLilac.Controls/MyListBox.cs index 02f4b1a..7486d55 100644 --- a/ContextMenuManager/BulePointLilac.Controls/MyListBox.cs +++ b/ContextMenuManager/BulePointLilac.Controls/MyListBox.cs @@ -184,8 +184,6 @@ namespace BulePointLilac.Controls } } - public int CtrCount { get => flpControls.Controls.Count; } - private readonly Label lblText = new Label { AutoSize = true @@ -198,9 +196,9 @@ namespace BulePointLilac.Controls }; private readonly FlowLayoutPanel flpControls = new FlowLayoutPanel { - Anchor = AnchorStyles.Top | AnchorStyles.Right, FlowDirection = FlowDirection.RightToLeft, AutoSizeMode = AutoSizeMode.GrowAndShrink, + Anchor = AnchorStyles.Right, AutoSize = true, Top = 0 }; @@ -242,14 +240,14 @@ namespace BulePointLilac.Controls { int space = 20.DpiZoom(); //为第一个ctr预留垂直滚动条的宽度 - if(CtrCount == 0) space += SystemInformation.VerticalScrollBarWidth; + if(flpControls.Controls.Count == 0) space += SystemInformation.VerticalScrollBarWidth; AddCtr(ctr, space); } public void AddCtr(Control ctr, int space) { - flpControls.Controls.Add(ctr); - ctr.Margin = new Padding(space); + ctr.Parent = flpControls; + ctr.Margin = new Padding(0, 0, space, 0); ctr.MouseEnter += (sender, e) => this.OnMouseEnter(null); ctr.MouseDown += (sender, e) => this.OnMouseEnter(null); CenterControl(ctr);