Redrawing and double buffering techniques for controls

Source: Internet
Author: User

Handling redraw and invalid operations:

Re-customizing control behavior and appearance

Void Invalidate (); void Invalidate (Rectangle); // invalidates a specific area of the control and sends a drawn message to the control; void Update (); // causes the control to redraw an invalid area within its workspace; void Refresh (); // equivalent to This.invalidate (true); Update ();

Dual Buffering Technology:

when the amount of data is large, the drawing may take a few seconds or longer, and sometimes flicker occurs, in order to solve these problems, you can use a double buffering technology to draw. Double buffering creates an object in memory that is consistent with the screen drawing area, drawing the graphic to the object in memory, and then copying the graphics on the object to the screen at once, which can greatly speed up the drawing. ;

1. Create a "virtual canvas" in memory;
New Bitmap (+);

2. get the Graphic reference for this memory canvas;
Graphics g = graphics.fromimage (BMP);

3. draw on this piece of memory canvas;
Ten Ten Ten Ten ); G.drawline ()  g.drawstring ()//...

4. Draw the memory canvas into the window and release the memory buffer;
 This 0 0 );

Note: with the doublebuffered attribute in the. NET Framework version 3 , you can use the dual buffering technology directly

Redrawing and double buffering techniques for controls

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.