Graphics.ResetClip Method
Resets the clip region of this Graphics object to an infinite region.
[Visual Basic] Public Sub ResetClip() [C#] public void ResetClip(); [C++] public: void ResetClip(); [JScript] public function ResetClip();
Return Value
This method does not return a value.
Remarks
When the clipping region of a Graphics object is infinite, items that this Graphics object draws are not clipped.
Example
[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:
- Creates a rectangle with upper-left corner at (0, 0) and sets the clipping region to this rectangle.
- Creates a second rectangle with upper-left corner at (100, 100) and sets the clipping region to the intersection of this rectangle and the current clipping region (the first rectangle).
- Fills a large rectangle that includes both previous rectangles with a solid blue brush.
- Resets the clipping region to infinite.
- Draws rectangles around the two clipping regions; it uses a black pen for the first clipping rectangle and a red pen for the second clipping region.
[Visual Basic, C#] The result is that only the intersection of the two rectangles is filled with blue.
[Visual Basic] Public Sub IntersectClipRectangleF(e As PaintEventArgs) ' Set clipping region. Dim clipRect As New Rectangle(0, 0, 200, 200) e.Graphics.SetClip(clipRect) ' Update clipping region to intersection of ' existing region with specified rectangle. Dim intersectRectF As New RectangleF(100F, 100F, 200F, 200F) e.Graphics.IntersectClip(intersectRectF) ' Fill rectangle to demonstrate effective clipping region. e.Graphics.FillRectangle(New SolidBrush(Color.Blue), 0, 0, _ 500, 500) ' Reset clipping region to infinite. e.Graphics.ResetClip() ' Draw clipRect and intersectRect to screen. e.Graphics.DrawRectangle(New Pen(Color.Black), clipRect) e.Graphics.DrawRectangle(New Pen(Color.Red), _ Rectangle.Round(intersectRectF)) End Sub [C#] public void IntersectClipRectangleF(PaintEventArgs e) { // Set clipping region. Rectangle clipRect = new Rectangle(0, 0, 200, 200); e.Graphics.SetClip(clipRect); // Update clipping region to intersection of existing region with new rectangle. RectangleF intersectRectF = new RectangleF(100.0F, 100.0F, 200.0F, 200.0F); e.Graphics.IntersectClip(intersectRectF); // Fill rectangle to demonstrate effective clipping region. e.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 500, 500); // Reset clipping region to infinite. e.Graphics.ResetClip(); // Draw clipRect and intersectRect to screen. e.Graphics.DrawRectangle(new Pen(Color.Black), clipRect); e.Graphics.DrawRectangle(new Pen(Color.Red), Rectangle.Round(intersectRectF)); }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
Graphics Class | Graphics Members | System.Drawing Namespace