Make a Scrollviewer not vertically scrollable - c#

I have a ScrollViewer which I don't wish to be scrollable vertically. I have its VerticalScrollBarVisibility set to Hidden, but I can still scroll with the mouse wheel.
Is it possible?

Set VerticalScrollBarVisibility to Disabled, and its content will only be given as much vertical space as exists in the viewport.
A value of Hidden still allows the content to extend beyond the viewport, and you can still issue scrolling commands; the scroll bar itself is hidden, but scrolling is not disabled.

Related

Managing Autoscroll

My Project is currently in C# Winforms.
I have a custom control that I am inserting on a flow layout panel.
I also have a header that fits above the Flow Layout.
I would like the flowlayout to scroll on the vertical axis while the whole panel scrolls along the horizontal axis.
The problem I am having is that the flowlayout when autoscroll is set to true makes use of both horizontal and vertical scroll
I need the header to scroll horizontally at the same time as the flowlayout but not show its own horizontal scrollbar. I also need the header to stay at the top of the Panel when the flowlayout scrolls vertically.
Thanks for the help
I have been trying out different combinations of autoscroll, wrapcontents and Autosize.

AutoScroll scrollbar hides part of my control

I have a control in C# that I want to AutoScroll. But when the scroll bar appears, it overlays part of the control. Is there any way I can make the control resize its contents to accomodate the scroll bar? This isn't a custom control; it's a standard .NET TabPage control. I really don't want to have to wire up a scroll bar manually...
I was able to work around this by adding a Panel control to the control I wanted to scroll, with a 12px right margin to accommodate the scrollbar. Not sure how this will look on high DPI settings, but it can always be tweaked.

Location of a control regardless of Vertical scroll bar effect

C# WinForms: if I want to have the location of a control on a panel regardless of where is the Vertical scroll bar, what should I use? I mean the form is large so we use scroll bar to move up and down, now I want that location to be independent of where I have set the scroll bar this.PointToClinet?
The Location property is already independent of the scrollbar position. A control at (0,0) stays at (0,0) in a panel with a scrollbar. What changes is the AutoScrollPosition property value. With a vertical scrollbar, the AutoScrollPosition.Y value becomes negative when the user scrolls down. Which makes whatever is inside the panel move up.
Trying to keep something in the same position even if the scrollbar is used is technically possible by correcting for AutoScrollPosition.Y. But doesn't work well in practice, whatever you are scrolling is doing the pogo, rapidly jumping up and down as you scroll. Which is caused by Windows blitting the scrolled pixels after which you redraw it back in the original position. Find a workaround for that problem in this post.

WinForms: How to avoid horizontal scroll bar with AutoScroll?

I'm writing a custom control that contains a list of items (child controls) that resize horizontally to fit the width of the control. If there are lots of items (or the control is resized so that it is not tall enough vertically) then a vertical scroll bar is necessary; but when the vertical scroll bar appears, the child controls are suddenly too wide, which causes a horizontal scroll bar to appear.
What's the proper way to guarantee that a horizontal scroll bar does not appear when it is not necessary, given that I am controlling the control placement manually (not relying on AnchorStyles)? (Note: I can't control the VScroll property manually because I'm on Compact Framework; and if an item's minimum width is wider than the client area then a horizontal scroll bar will be required legitimately.)
What I did in a similar situation was after every time I added an item to the list I detected whether the scroll bar was visible or not and adjusted my the width manually.
What I did to detect whether the scroll bar was showing was either:
Test for the WS_VSCROLL was set on the control via P/Invoke via GetWindowLong().
Scan the control's children for a vertical scroll bar control.
It depends on how the control handles scroll bars as to which one is correct.
Also this was on Windows, not in the CF so I'm not sure if this will work exactly the same way.
Take the width of the vertical scrollbar into account when calculating the required width for your child controls:
System.Windows.Forms.SystemInformation.VerticalScrollBarWidth

scroll in usercontrol

In windows forms
I want to activate scroll to my usercontrol,
i activated autoscroll,
but the horizontal scroll is not appearing.
i have kept my control n tablelayout panel..
Help me for the horizontal scroll..
AutoScroll means that the scrollbar(s) will appear when some content sticks out of the Client Area. When you use a TableLayout (with Docking = Fill) then the AutoScroll does not kick in.
Turn of Docking for the TableLayout and set its Width/Height larger than the Form. You will see AutoScroll in the Designer.

Categories

Resources