How to hide the vertical scroll bar in a .NET ListView Control in Details mode

前端 未结 6 1555
终归单人心
终归单人心 2020-12-01 17:11

I\'ve got a ListView control in Details mode with a single column. It\'s on a form that is meant to only be used with the keyboard, mostly with the up/down arrows for scrol

6条回答
  •  一生所求
    2020-12-01 17:49

    Since ShowScrollBar didn't work, maybe this helps:

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
    
    private const int WM_VSCROLL = 0x115;
    private const int SB_LINEDOWN = 1;
    
    public Form1()
    {
        InitializeComponent();
        for (int i = 0; i < 100; i++)
            listView1.Items.Add("foo" + i);
        listView1.Scrollable = false;
    }
    
    private void listView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        SendMessage(listView1.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
    }
    

提交回复
热议问题