C#判断ListBox是否显示了水平滚动条/横向滚动条

private static class NativeMethods
        {
            public const int GWL_STYLE = -16;
            public const long WS_HSCROLL = 0x00100000;

            [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
            internal static extern uint GetWindowLong(IntPtr hwnd, int nIndex);

            internal static bool HasHorizontalScrollbar(Control control)
            {
                long i = (GetWindowLong(control.Handle, GWL_STYLE) & WS_HSCROLL);
                return i > 0;
            }
        }

 

你可能感兴趣的