Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 有没有办法获得滚动条的高度和宽度?_C#_.net_Listview_Scrollbar - Fatal编程技术网

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

C# 有没有办法获得滚动条的高度和宽度?,c#,.net,listview,scrollbar,C#,.net,Listview,Scrollbar,我正在尝试获取ListView上显示的滚动条的高度和宽度。有没有一个简单的方法可以做到这一点?我做了一些谷歌搜索,它看起来可能是一个系统设置。我只是不知道该去哪里找。是的,这是一个系统设置。使用和 名称空间:System.Windows.Forms 在.Net CF上,其中SystemInformation.HorizontalScrollBarHeight和SystemInformation.VerticalScrollBarWidth不存在,需要一些p/Invoke: public seal

我正在尝试获取ListView上显示的滚动条的高度和宽度。有没有一个简单的方法可以做到这一点?我做了一些谷歌搜索,它看起来可能是一个系统设置。我只是不知道该去哪里找。

是的,这是一个系统设置。使用和

名称空间:System.Windows.Forms


在.Net CF上,其中
SystemInformation.HorizontalScrollBarHeight
SystemInformation.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;
}

谢谢,省去了我很多麻烦