How to get horizontal scrollbar height in ListView

Can someone tell me how can I get the height of the horizontal scrollbar in a ListView in C #? is it the same as the standard horizontal scrollbar, if so is there any window function that returns this? I mainly use ListView with OwnerDraw and want to know exactly how big my client area is, which excludes the ColumnHeader area and the HorizontalScrollbar area.

thanks

+3
source share
3 answers

Control.ClientRectangle excludes scrollbars and borders.

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

    Console.WriteLine(listView1.ClientRectangle);
    Console.WriteLine(listView1.Size);
+2
source

.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;
}
0

Source: https://habr.com/ru/post/1713463/


All Articles