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 开发者_如何学Pythonscroll 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.
精彩评论