![](/img/trans.png)
[英]How To Avoid Horizontal Scrollbar During Proportional Resize of WPF ListView Columns
[英]How to get height of horizontal scrollbar in a ListView
任何人都可以告诉我如何在C#中的ListView中获得水平滚动条的高度? 它是否与标准水平滚动条相同,如果有的话,是否有任何窗口函数返回? 基本上我正在使用带有OwnerDraw的ListView,并想知道我的客户区有多大,它排除了ColumnHeader区域和HorizontalScrollbar区域。
谢谢
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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.