From 55fe87d8f3b6d196ee33b00c35a2564c7a5e8f55 Mon Sep 17 00:00:00 2001 From: Sunny Date: Fri, 29 Jul 2022 10:21:21 +0800 Subject: [PATCH] =?UTF-8?q?*=20UIDataGridView:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BA=86ScrollBars=E4=B8=BANone=E6=97=B6=E4=BB=8D=E7=84=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=BB=9A=E5=8A=A8=E6=9D=A1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20*=20UIDataGridView:=20=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E5=8D=95=E8=A1=8C=E6=97=B6=E8=A1=A8=E6=A0=BC=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E4=BD=8E=E6=97=B6=EF=BC=8C=E5=9E=82=E7=9B=B4=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=9D=A1=E6=8B=96=E6=8B=BD=E8=87=B3=E5=BA=95=E9=83=A8=E5=87=BA?= =?UTF-8?q?=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UIDataGridView.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/SunnyUI/Controls/UIDataGridView.cs b/SunnyUI/Controls/UIDataGridView.cs index f1d0cd82..8b91530e 100644 --- a/SunnyUI/Controls/UIDataGridView.cs +++ b/SunnyUI/Controls/UIDataGridView.cs @@ -41,6 +41,8 @@ * 2022-06-22: V3.2.0 删除 ShowRect、ShowGridLine、RowHeight三个属性 * 2022-07-11: V3.2.1 修复一处滚动条的显示位置 * 2022-07-11: V3.2.1 增加滚动条边框线的设置 + * 2022-07-28: V3.2.2 修复了ScrollBars为None时仍然显示滚动条的问题 + * 2022-07-28: V3.2.2 修复了单行时表格高度低时,垂直滚动条拖拽至底部出错的问题 ******************************************************************************/ using System; @@ -286,7 +288,11 @@ namespace Sunny.UI private void VBarValueChanged(object sender, EventArgs e) { - FirstDisplayedScrollingRowIndex = VBar.Value; + if (RowCount == 0) return; + int idx = VBar.Value; + if (idx < 0) idx = 0; + if (idx >= RowCount) idx = RowCount - 1; + FirstDisplayedScrollingRowIndex = idx; } private void HorizontalScrollBar_ValueChanged(object sender, EventArgs e) @@ -316,7 +322,7 @@ namespace Sunny.UI { VBar.Maximum = RowCount - DisplayedRowCount(false); VBar.Value = FirstDisplayedScrollingRowIndex; - VBar.Visible = true; + VBar.Visible = ScrollBars == ScrollBars.Vertical || ScrollBars == ScrollBars.Both; } else { @@ -329,7 +335,7 @@ namespace Sunny.UI HBar.Value = HorizontalScrollBar.Value; HBar.BoundsWidth = HorizontalScrollBar.LargeChange; HBar.LargeChange = HorizontalScrollBar.LargeChange;//.Maximum / VisibleColumnCount(); - HBar.Visible = true; + HBar.Visible = ScrollBars == ScrollBars.Horizontal || ScrollBars == ScrollBars.Both; } else {