Only horizontal scrolling in a panel

前端 未结 4 625
情歌与酒
情歌与酒 2021-01-21 03:42

How do I set my panel so it will only scroll horizontal? I have tried:

this.VerticalScroll.Enabled = false;

But it doesn\'t work.

相关标签:
4条回答
  • 2021-01-21 04:12

    It works using this code in my panel:

        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            ShowScrollBar(this.Handle, 1, false);
            base.WndProc(ref m);
        }
    
        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow);
    
    0 讨论(0)
  • 2021-01-21 04:17

    Try this instead for 'only' scrolling horizontal.
    (auto scroll needs to be false b4 it will accept changes)

    mypanel.AutoScroll = false;
    mypanel.VerticalScroll.Enabled = false;
    mypanel.VerticalScroll.Visible = false;
    mypanel.VerticalScroll.Maximum = 0;
    mypanel.AutoScroll = true;
    
    0 讨论(0)
  • 2021-01-21 04:27

    If your panel does not perform AutoScroll, you can use its VScroll property:

    yourPanel.VScroll = false;
    
    0 讨论(0)
  • 2021-01-21 04:29

    you can try

    panel.AutoScroll = true;
    panel.HorizontalScroll.Enabled=false;
    panel.HorizontalScroll.Visible = false;
    
    0 讨论(0)
提交回复
热议问题