I have a panel (Windows Forms) and I want to disable a panels horizontal scrollbar. I tried this:
HorizontalScroll.Enabled = false;
But that wouldn't work.
How can I do this?
Web browsers do not take into account the width of the scrollbar on the side of a page when computing width values, so since we have a page that is longer than a single viewport, part of our page is being rendered behind the vertical scroll bar, causing the browser to display a horizontal scroll bar.
2. Type "Remove Scrollbars" (without quotes) in the search box and press "Enter." Click the "Remove Scrollbars" option located on top of the search results.
For horizontal scrollable bar use the x and y-axis. Set the overflow-y: hidden; and overflow-x: auto; that will automatically hide the vertical scroll bar and present only the horizontal scrollbar. The white-space: nowrap; property is used to wrap text in a single line.
Try to implement this way, it will work 100%
panel.HorizontalScroll.Maximum = 0; panel.AutoScroll = false; panel.VerticalScroll.Visible = false; panel.AutoScroll = true;
If you feel like desecrating your code you could try this very "hackish" solution:
[DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow); private enum ScrollBarDirection { SB_HORZ = 0, SB_VERT = 1, SB_CTL = 2, SB_BOTH = 3 } protected override void WndProc(ref System.Windows.Forms.Message m) { ShowScrollBar(panel1.Handle, (int)ScrollBarDirection.SB_BOTH, false); base.WndProc(ref m); }
I'm currently using the code above to prevent a 3rd party UserControl from showing its scrollbars. They weren't exposing any proper ways of hiding them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With