检查TreeView ScrollBar可见性

Adr*_*rao 4 c# treeview scrollbar winforms

如何检查TreeView中的Vertical ScrollBar是否可见?

alb*_*ert 8

你必须做一些p/invoke来获得TreeView的风格.

    private const int GWL_STYLE = -16;
    private const int WS_VSCROLL = 0x00200000;
    [DllImport("user32.dll", ExactSpelling = false, CharSet = CharSet.Auto)]
    private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

    bool VScrollVisible()
    {
        int style = GetWindowLong(myTreeView.Handle, GWL_STYLE);
        return  ((style & WS_VSCROLL) != 0);
    }
Run Code Online (Sandbox Code Playgroud)