The OnPaint Method

The OnPaint method for a form or a control is called by the operating system whenever part or all of that form or control is obscured by another form or control and needs to be redrawn. A Graphics object is passed as part of the PaintEventArgs parameter for the OnPaint method. Using this Graphics object, you redraw the portion of the display that has been obscured. You use the ClipRectangle property, which defines a Rectangle structure that represents the area of the display that has been obscured, to test whether you need to redraw your graphics. Testing the ClipRectangle before redrawing your graphics reduces unnecessary processing of commands.

Note

Note that the Paint event handler for a form or a control, such as Form1_Paint ...

Get Microsoft® .NET Compact Framework (Core Reference) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.