如何获取 DataGridView 控件上滚动条的大小?
如何获取控件(例如 DataGridView)上出现的水平滚动条的高度和/或垂直滚动条的宽度?
How can I get the height of horizontal and/or width of vertical scrollbar that appears on control (e.g. DataGridView)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
DataGridView 上显示的滚动条将与计算机上的所有其他滚动条具有相同的水平高度和垂直宽度。这些大小由活动 Windows 主题定义,并由 .NET Framework 在
SystemInformation
类:VerticalScrollBarWidth
HorizontalScrollBarHeight
同一类还提供有关当前系统环境中默认滚动条参数的附加信息。
如果您需要知道哪些滚动条当前在控件上可见,请使用其
ScrollBars
属性。这获取或设置ScrollBars 值
,可以是
无
、水平
、垂直
或两者
。The scrollbars that appear on your DataGridView will be the same horizontal height and vertical width as all of the other scrollbars on your computer. These sizes are defined by the active Windows theme, and exposed by the .NET Framework in the following properties of the
SystemInformation
class:VerticalScrollBarWidth
HorizontalScrollBarHeight
The same class also provides additional information about the default scrollbar parameters in the current system environment.
If you need to know which scrollbars are currently visible on your control, use its
ScrollBars
property. This gets or sets one of theScrollBars
values, eitherNone
,Horizontal
,Vertical
, orBoth
.将其放入资源字典中:检查一下:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.scrollbars.aspx
无论 的值如何通过此属性,滚动条仅在需要时才显示。使用此属性可以防止出现滚动条。例如,当您想要提供用于滚动的替代用户界面 (UI) 时,这很有用。
http://msdn.microsoft.com/en-us /library/system.windows.forms.scrollbars.aspx
Place this in your resource dictionary:check this out:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.scrollbars.aspx
Regardless of the value of this property, scroll bars are shown only when they are needed. Use this property to prevent scroll bars from appearing. This is useful, for example, when you want to provide an alternative user interface (UI) for scrolling.
http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollbars.aspx
使用:
Use: