有没有办法获得滚动条的高度和宽度?
我正在尝试获取ListView上显示的滚动条的高度和宽度。 是否有捷径可寻? 我做了一些google’ing,看起来它可能是一个系统设置。 我只是不确定在哪里看。
是的,这是一个系统设置。 使用SystemInformation.HorizontalScrollBarHeight和SystemInformation.VerticalScrollBarWidth 。
命名空间 :System.Windows.Forms
在.Net CF上, SystemInformation.HorizontalScrollBarHeight
和SystemInformation.VerticalScrollBarWidth
不存在,需要一些P / Invoke:
上述就是C#学习教程:有没有办法获得滚动条的高度和宽度?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
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; }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/997389.html