In winform.net development, you can use a panel or UserControl to place graphics or other controls as a container with scroll bars. We can set the control's BackgroundImage property to set the control's background picture, but the background image will scroll with the control's content scrolling, and there is a bad effect of background fragmentation. In the development practice, the background picture of the control is not scrolled with the control scrolling.
In the B/s development, developers can use the "background-attachment:fixed" CSS style to secure the background image of the HTML document, so that it does not scroll with the content scrolling. But it doesn't function in winform.net development.
So yuan someone began a long way to repair the long, everywhere and search, incredibly come up with a solution, in this use to find problems, analysis and solve the problem of the steps to one by one, hoping to meet the same problem with a little inspiration.
Find problems
First of all, winform.net scrolling background is also the principle of scrolling. As shown in the following illustration, the author places a panel control on a form, sets a larger background picture, and then sets the control's Auotscroll value to true, setting the control's AutoScrollMinSize property value to the size of the background picture, the control is shown below Displays the scroll bar as shown.
The author drags down the vertical scroll bar of the control, causing the contents of the control to scroll. By default, the Windows operating system automatically scrolls through the Control client area view, such as a scrolling operation that results in a 100-pixel scrolling distance, and Windows automatically translates the contents of the control client area up to 100 pixels, so that a new 100-pixel-high customer area is released underneath the control , this client area is the invalid rectangle for the control, and the Windows operating system sends a WM_PAINT message to the control, causing the control's paint event to be triggered, calling the program code to redraw the area of the 100-pixel height.