Each form, picture box, and frame control has a ClipControls property. ClipControls is a Boolean property that, when set to True, causes the container to define a clipping region when painting the container around all controls except:
By setting the ClipControls property to False, you can improve the speed with which a form paints to the screen. The speed improvement is greatest on forms with many controls that do not overlap, like dialog boxes.
Clipping is the process of determining which parts of a form or container are painted when the form or container is displayed. The outline used to determine what parts of the form or container are painted or "clipped" defines the clipping region for that form or container. Clipping regions are useful when a Windows – based application needs to save one part of the display and simultaneously repaint the rest.
The default setting of ClipControls is True. When the ClipControls property is True, Windows defines a clipping region for the background of the form or container before a Paint event. This clipping region surrounds all nongraphical controls. When using ClipControls, labels act like graphical controls.
During a Paint event, Windows repaints only the background inside the clipping region, avoiding the nongraphical controls. Figure 12.8 shows a form with four controls, a box painted with the Line method, and the clipping region created for that form by setting ClipControls to True. Notice that the clipping region did not clip around the label or shape controls on the form. The box drawn in the background with the Line method paints only in the clipping region.
Figure 12.8 The clipping region created when ClipControls is True
When ClipControls is False, Windows does not define a clipping region for the background of the form or container before a Paint event. Also, output from graphics methods within the Paint event appears only in the parts of the form or container that need to be repainted. Since calculating and managing a clipping region takes time, setting ClipControls to False may cause forms with many nonoverlapping controls (such as complex dialog boxes) to display faster.
Note Avoid nesting controls with ClipControls set to True inside controls with ClipControls set to False. Doing so may result in the nested controls not repainting correctly. To fix this, set ClipControls to True for both the containers and the controls.
For More Information See "Optimizing Display Speed" in "Designing for Performance and Compatibility."