Graphics.Clip Property
.NET Framework 2.0
Gets or sets a Region that limits the drawing region of this Graphics.
Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)
Assembly: System.Drawing (in system.drawing.dll)
To determine whether the clipping region is infinite, retrieve the Clip property and call its IsInfinite method.
The following code example demonstrates the use of the Clip property. This example is designed to be used with Windows Forms. Paste the code into a form and call the SetAndFillClip method when handling the form's Paint event, passing e as PaintEventArgs.
private: void SetAndFillClip( PaintEventArgs^ e ) { // Set the Clip property to a new region. e->Graphics->Clip = gcnew System::Drawing::Region( Rectangle(10,10,100,200) ); // Fill the region. e->Graphics->FillRegion( Brushes::LightSalmon, e->Graphics->Clip ); // Demonstrate the clip region by drawing a string // at the outer edge of the region. e->Graphics->DrawString( "Outside of Clip", gcnew System::Drawing::Font( "Arial",12.0F,FontStyle::Regular ), Brushes::Black, 0.0F, 0.0F ); }
private void SetAndFillClip(PaintEventArgs e)
{
// Set the Clip property to a new region.
e.get_Graphics().set_Clip(new Region(new Rectangle(10, 10, 100, 200)));
// Fill the region.
e.get_Graphics().FillRegion(Brushes.get_LightSalmon(),
e.get_Graphics().get_Clip());
// Demonstrate the clip region by drawing a string
// at the outer edge of the region.
e.get_Graphics().DrawString("Outside of Clip",
new Font("Arial", 12, FontStyle.Regular),
Brushes.get_Black(), 0, 0);
} //SetAndFillClip
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: