有没有办法获得滚动条的高度和宽度?

我正在尝试获取ListView上显示的滚动条的高度和宽度。 是否有捷径可寻? 我做了一些google’ing,看起来它可能是一个系统设置。 我只是不确定在哪里看。

是的,这是一个系统设置。 使用SystemInformation.Horizo​​ntalScrollBarHeight和SystemInformation.VerticalScrollBarWidth 。

命名空间 :System.Windows.Forms

在.Net CF上, SystemInformation.HorizontalScrollBarHeightSystemInformation.VerticalScrollBarWidth不存在,需要一些P / Invoke:

 public sealed class Native { public static Int32 GetVerticalScrollbarWidth() { return GetSystemMetrics(SM_CXVSCROLL); } public Int32 GetHorizontalScrollbarHeight() { return GetSystemMetrics(SM_CYHSCROLL); } [DllImport("coredll.dll", SetLastError = true)] public static extern Int32 GetSystemMetrics(Int32 index); public const Int32 SM_CXVSCROLL = 2, SM_CYHSCROLL = 3; }