誰能告訴我如何獲得C#中ListView中水平滾動條的高度?它是否與標準的水平滾動條相同,如果有的話,是否有任何窗口函數返回?基本上我使用ListView和OwnerDraw,並且想知道排除ColumnHeader區域和HorizontalScrollbar區域的客戶區域有多大。如何獲得ListView中水平滾動條的高度
感謝
誰能告訴我如何獲得C#中ListView中水平滾動條的高度?它是否與標準的水平滾動條相同,如果有的話,是否有任何窗口函數返回?基本上我使用ListView和OwnerDraw,並且想知道排除ColumnHeader區域和HorizontalScrollbar區域的客戶區域有多大。如何獲得ListView中水平滾動條的高度
感謝
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.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;
}
感謝弗雷德裏克! – Jefe 2009-07-27 09:28:04