Freigeben über


Graphics.Clip-Eigenschaft

Ruft eine Region ab, die den Zeichenbereich dieses Graphics begrenzt, oder legt diese fest.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

Syntax

'Declaration
Public Property Clip As Region
'Usage
Dim instance As Graphics
Dim value As Region

value = instance.Clip

instance.Clip = value
public Region Clip { get; set; }
public:
property Region^ Clip {
    Region^ get ();
    void set (Region^ value);
}
/** @property */
public Region get_Clip ()

/** @property */
public void set_Clip (Region value)
public function get Clip () : Region

public function set Clip (value : Region)

Eigenschaftenwert

Eine Region, die für dieses Graphics den Bereich begrenzt, in dem gegenwärtig gezeichnet werden kann.

Hinweise

Mit einer Abfrage der Clip-Eigenschaft und einem Aufruf der entsprechenden IsInfinite-Methode können Sie bestimmen, ob der Ausschneidebereich unbestimmt ist.

Beispiel

Im folgenden Codebeispiel wird die Verwendung der Clip-Eigenschaft veranschaulicht. Dieses Beispiel ist für die Verwendung mit Windows Forms vorgesehen. Fügen Sie den Code in ein Formular ein, und rufen Sie beim Behandeln des Paint-Ereignisses des Formulars die SetAndFillClip-Methode auf, wobei Sie e als PaintEventArgs übergeben.

Private Sub SetAndFillClip(ByVal e As PaintEventArgs)

    ' Set the Clip property to a new region.
    e.Graphics.Clip = New Region(New 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", _
        New Font("Arial", 12.0F, FontStyle.Regular), _
        Brushes.Black, 0.0F, 0.0F)

End Sub
private void SetAndFillClip(PaintEventArgs e)
{

    // Set the Clip property to a new region.
    e.Graphics.Clip = new Region(new 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", new 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->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

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

Graphics-Klasse
Graphics-Member
System.Drawing-Namespace