How do I disable the horizontal scrollbar in a Panel

前端 未结 11 1923
别那么骄傲
别那么骄傲 2020-12-01 12:13

I have a panel (Windows Forms) and I want to disable a panels horizontal scrollbar. I tried this:

HorizontalScroll.Enabled = false;

But tha

11条回答
  •  悲哀的现实
    2020-12-01 12:37

    I think that you're having this problem because the AutoScroll property of your panel is set to true. I made a test solution (.NET 3.5) and discovered the following:

    If you try this:

    panel.AutoScroll = true;
    panel.HorizontalScroll.Enabled = false;
    panel.HorizontalScroll.Visible = false;
    

    the HorizontalScroll.Enabled and .Visible aren't changed to false (assuming the panel has controls within that cause autoscroll to show the horizontal scroll bar). It seems that you must disable AutoScroll to be able to change these properties around manually.

提交回复
热议问题