Search code examples
c#winformshorizontal-scrollingwndproc

C# ListView Disable Horizontal Scrollbar


is there a way I can stop the horizontal scroll bar from ever showing up in a listview? I want the vertical scroll bar to show when needed but I want the horizontal scroll bar to never show up.

I would imagine it would have something to do with WndProc?

Thanks


Solution

  • You could try something like this, I used in a project once and it worked:

    [DllImport ("user32")]
    private static extern long ShowScrollBar (long hwnd , long wBar, long bShow);
    long SB_HORZ = 0;
    long SB_VERT = 1;
    long SB_BOTH = 3;
    
    private void HideHorizontalScrollBar ()
    {
        ShowScrollBar(listView1.Handle.ToInt64(), SB_HORZ, 0);
    }
    

    Hope it helps.