Graphics.Clip プロパティ

定義

この Graphics の描画領域を限定する Region を取得または設定します。

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 のうち、現在描画に使用できる部分を限定する Graphics

次のコード例では、 プロパティの使用方法を Clip 示します。 この例は、Windows フォームで使用するように設計されています。 フォームにコードを貼り付け、フォームのイベントをSetAndFillClip処理するときに メソッドをPaint呼び出し、 を としてPaintEventArgs渡しますe

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 影響しません。 クリップ領域を変更するには、プロパティ値を ClipRegion しいオブジェクトに置き換えます。 クリッピング領域が無限であるかどうかを判断するには、 プロパティを Clip 取得し、そのメソッドを IsInfinite 呼び出します。

適用対象