简体   繁体   English

如何在ListView中获取水平滚动条的高度

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

Can anyone tell me how can I get the height of horizontal scrollbar in ListView in C#? 任何人都可以告诉我如何在C#中的ListView中获得水平滚动条的高度? is it the same as the standard Horizontal scrollbar, if so is there any windows function that return that? 它是否与标准水平滚动条相同,如果有的话,是否有任何窗口函数返回? basically I'm using ListView with OwnerDraw and want to know exactly how big is my client area which excludes ColumnHeader area and HorizontalScrollbar area. 基本上我正在使用带有OwnerDraw的ListView,并想知道我的客户区有多大,它排除了ColumnHeader区域和Horizo​​ntalScrollbar区域。

Thanks 谢谢

Control.ClientRectangle excludes scrollbars and borders. Control.ClientRectangle排除滚动条和边框。

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

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

On .Net CF, where SystemInformation.HorizontalScrollBarHeight and SystemInformation.VerticalScrollBarWidth don't exist, some P/Invoke is required: 在.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.

相关问题 WPF ListView列按比例调整大小时如何避免水平滚动条 - How To Avoid Horizontal Scrollbar During Proportional Resize of WPF ListView Columns C#WPF:通过将高度属性设置为“自动”的ListView中的水平滚动条防止最后一项覆盖 - C# WPF: prevent last item cover by horizontal scrollbar in ListView with Height property set to “Auto” 如何在没有ListView滚动条的情况下获取ActualWidth - How to get the ActualWidth without scrollbar of a ListView 如何在 uwp 的滚动查看器中获取滚动条高度? - How to get scrollbar height in scrollviewer in uwp? Windows窗体ListView缺少水平滚动条 - Windows Forms ListView missing horizontal scrollbar C# ListView 禁用水平滚动条 - C# ListView Disable Horizontal Scrollbar 在Winforms中从ListView禁用水平ScrollBar - Disable the Horizontal ScrollBar from ListView in Winforms 如何使WPF ListView处于水平状态,并且将包含的图像拉伸到合适的高度? - How to make WPF ListView horizontal with contained image stretched to fit the height? 我可以使用水平滚动条从ListView的总列宽中获取可见列宽吗 - Can i get the Visible Column Width out of total column width in ListView with Horizontal scrollbar 有没有办法获得滚动条的高度和宽度? - Is there a way to get the scrollbar height and width?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM