次の方法で共有


Graphics.SetClip メソッド (Rectangle)

この Graphics オブジェクトのクリッピング領域を Rectangle 構造体で指定された四角形に設定します。

Overloads Public Sub SetClip( _
   ByVal rect As Rectangle _)
[C#]
public void SetClip(Rectanglerect);
[C++]
public: void SetClip(Rectanglerect);
[JScript]
public function SetClip(
   rect : Rectangle);

パラメータ

  • rect
    新しいクリップ領域を表す Rectangle 構造体。

戻り値

このメソッドは値を返しません。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • クリッピング領域に使用する小さな四角形を作成します。
  • クリッピング領域を四角形に設定します。
  • 黒いソリッド ブラシで大きな四角形を塗りつぶします。

[Visual Basic, C#] 黒で塗りつぶされた小さな四角形が生成されます。

 
Public Sub SetClipRectangle(e As PaintEventArgs)
' Create rectangle for clipping region.
Dim clipRect As New Rectangle(0, 0, 100, 100)
' Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect)
' Fill rectangle to demonstrate clip region.
e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
500, 300)
End Sub
        
[C#] 
public void SetClipRectangle(PaintEventArgs e)
{
// Create rectangle for clipping region.
Rectangle clipRect = new Rectangle(0, 0, 100, 100);
// Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect);
// Fill rectangle to demonstrate clip region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

Graphics クラス | Graphics メンバ | System.Drawing 名前空間 | Graphics.SetClip オーバーロードの一覧