簡體   English   中英

有沒有辦法獲得滾動條的高度和寬度?

[英]Is there a way to get the scrollbar height and width?

我正在嘗試獲取ListView上顯示的滾動條的高度和寬度。 是否有捷徑可尋? 我做了一些google'ing,看起來它可能是一個系統設置。 我只是不確定在哪里看。

是的,這是一個系統設置。 使用SystemInformation.Horizo​​ntalScrollBarHeightSystemInformation.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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM