簡體   English   中英

如何在ListView中獲取水平滾動條的高度

[英]How to get height of horizontal scrollbar in a ListView

任何人都可以告訴我如何在C#中的ListView中獲得水平滾動條的高度? 它是否與標准水平滾動條相同,如果有的話,是否有任何窗口函數返回? 基本上我正在使用帶有OwnerDraw的ListView,並想知道我的客戶區有多大,它排除了ColumnHeader區域和Horizo​​ntalScrollbar區域。

謝謝

Control.ClientRectangle排除滾動條和邊框。

    listView1.Scrollable = true;
    Console.WriteLine(listView1.ClientRectangle);
    Console.WriteLine(listView1.Size);
    listView1.Scrollable = false;

    Console.WriteLine(listView1.ClientRectangle);
    Console.WriteLine(listView1.Size);

在.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