C # Discovery Tour: Winform.net to develop a scrollable control with a fixed background picture

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.