* UIDataGridView: 增加了可设置垂直滚动条宽度的属性

This commit is contained in:
Sunny 2022-10-14 16:44:38 +08:00
parent 998df06fa3
commit 5ba7bf809f
2 changed files with 48 additions and 5 deletions

View File

@ -43,6 +43,7 @@
* 2022-07-11: V3.2.1 线
* 2022-07-28: V3.2.2 ScrollBars为None时仍然显示滚动条的问题
* 2022-07-28: V3.2.2
* 2022-10-14: V3.2.6
******************************************************************************/
using System;
@ -115,6 +116,32 @@ namespace Sunny.UI
HorizontalScrollBar.VisibleChanged += HorizontalScrollBar_VisibleChanged;
}
private int scrollBarWidth = 0;
[DefaultValue(0), Category("SunnyUI"), Description("垂直滚动条宽度,最小为原生滚动条宽度")]
public int ScrollBarWidth
{
get => scrollBarWidth;
set
{
scrollBarWidth = value;
SetScrollInfo();
}
}
private int scrollBarHandleWidth = 6;
[DefaultValue(6), Category("SunnyUI"), Description("垂直滚动条滑块宽度,最小为原生滚动条宽度")]
public int ScrollBarHandleWidth
{
get => scrollBarHandleWidth;
set
{
scrollBarHandleWidth = value;
if (VBar != null) VBar.FillWidth = value;
}
}
/// <summary>
/// 禁止控件跟随窗体缩放
/// </summary>
@ -438,11 +465,13 @@ namespace Sunny.UI
return;
}
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth(), ScrollBarWidth);
if (BorderStyle == BorderStyle.FixedSingle)
{
VBar.Left = Width - ScrollBarInfo.VerticalScrollBarWidth() - 2;
VBar.Left = Width - barWidth - 2;
VBar.Top = 1;
VBar.Width = ScrollBarInfo.VerticalScrollBarWidth() + 1;
VBar.Width = barWidth + 1;
VBar.Height = Height - 2;
VBar.BringToFront();
@ -454,9 +483,9 @@ namespace Sunny.UI
}
else
{
VBar.Left = Width - ScrollBarInfo.VerticalScrollBarWidth() - 1;
VBar.Left = Width - barWidth - 1;
VBar.Top = 0;
VBar.Width = ScrollBarInfo.VerticalScrollBarWidth() + 1;
VBar.Width = barWidth + 1;
VBar.Height = Height;
VBar.BringToFront();

View File

@ -65,6 +65,19 @@ namespace Sunny.UI
private bool isScrollUp = true;
private bool largeChange = true;
private int fillWidth = 6;
[DefaultValue(6)]
public int FillWidth
{
get => fillWidth;
set
{
fillWidth = Math.Max(6, value);
Invalidate();
}
}
public event EventHandler ValueChanged;
protected override void Dispose(bool disposing)
@ -141,7 +154,8 @@ namespace Sunny.UI
private Rectangle GetValueRect()
{
return new Rectangle(Width / 2 - 3, ValueToPos(scrollValue), 6, barHeight);
int w = Math.Min(Width - 2, FillWidth);
return new Rectangle(Width / 2 - FillWidth / 2, ValueToPos(scrollValue), FillWidth, barHeight);
}
private int ValueToPos(int value)