Graphics.Clip Graphics.Clip Graphics.Clip Graphics.Clip Property

定義

この Region の描画領域を限定する Graphics を取得または設定します。Gets or sets a Region that limits the drawing region of this Graphics.

public:
 property System::Drawing::Region ^ Clip { System::Drawing::Region ^ get(); void set(System::Drawing::Region ^ value); };
public System.Drawing.Region Clip { get; set; }
member this.Clip : System.Drawing.Region with get, set
Public Property Clip As Region

プロパティ値

この Region のうち、現在描画に使用できる部分を限定する GraphicsA Region that limits the portion of this Graphics that is currently available for drawing.

次のコード例は、の使用を示します、Clipプロパティ。The following code example demonstrates the use of the Clip property. この例は、Windows フォームで使用する設計されています。This example is designed to be used with Windows Forms. フォームと呼び出しにコードを貼り付けます、SetAndFillClipメソッド、フォームを処理するときにPaint渡すイベントeとしてPaintEventArgsします。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.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 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

注釈

変更、Regionによって返されるオブジェクト、Clipプロパティでは、後続の描画には影響しません、Graphicsオブジェクト。Modifying the Region object returned by the Clip property does not affect subsequent drawing with the Graphics object. クリップ領域を変更するには、置換、Clipプロパティの値を新しいRegionオブジェクト。To change the clip region, replace the Clip property value with a new Region object. クリッピング領域が有限かどうかを確認するのには、取得、Clipプロパティと呼び出しのIsInfiniteメソッド。To determine whether the clipping region is infinite, retrieve the Clip property and call its IsInfinite method.

適用対象