Graphics.DrawRectangleとは? わかりやすく解説

Graphics.DrawRectangle メソッド (Pen, Rectangle)

Rectangle 構造体指定され四角形描画ます。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub DrawRectangle ( _
    pen As Pen, _
    rect As Rectangle _
)
Dim instance As Graphics
Dim pen As Pen
Dim rect As Rectangle

instance.DrawRectangle(pen, rect)
public void DrawRectangle (
    Pen pen,
    Rectangle rect
)
public:
void DrawRectangle (
    Pen^ pen, 
    Rectangle rect
)
public void DrawRectangle (
    Pen pen, 
    Rectangle rect
)
public function DrawRectangle (
    pen : Pen, 
    rect : Rectangle
)

パラメータ

pen

四角形の色、幅、およびスタイル決定する Pen

rect

描画する四角形を表す Rectangle 構造体

例外例外
例外種類条件

ArgumentNullException

pennull 参照 (Visual Basic では Nothing) です。

使用例使用例

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

Public Sub DrawRectangleRectangle(ByVal
 e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New
 Pen(Color.Black, 3)

    ' Create rectangle.
    Dim rect As New Rectangle(0,
 0, 200, 200)

    ' Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, rect)
End Sub
public void DrawRectangleRectangle(PaintEventArgs
 e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create rectangle.
    Rectangle rect = new Rectangle(0, 0, 200, 200);
             
    // Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, rect);
}
public:
   void DrawRectangleRectangle( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create rectangle.
      Rectangle rect = Rectangle(0,0,200,200);

      // Draw rectangle to screen.
      e->Graphics->DrawRectangle( blackPen, rect );
   }
public void DrawRectangleRectangle(PaintEventArgs
 e) 
{
    // Create pen.
    Pen blackPen =  new Pen(Color.get_Black(), 3);

    // Create rectangle.
    Rectangle rect =  new Rectangle(0, 0, 200, 200);

    // Draw rectangle to screen.
    e.get_Graphics().DrawRectangle(blackPen, rect);
} //DrawRectangleRectangle
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Graphics.DrawRectangle メソッド

座標ペア、幅、および高さで指定され四角形描画ます。
オーバーロードの一覧オーバーロードの一覧

名前 説明
Graphics.DrawRectangle (Pen, Rectangle) Rectangle 構造体指定され四角形描画ます。

.NET Compact Framework によってサポートされています。

Graphics.DrawRectangle (Pen, Int32, Int32, Int32, Int32) 座標ペア、幅、および高さで指定され四角形描画ます。

.NET Compact Framework によってサポートされています。

Graphics.DrawRectangle (Pen, Single, Single, Single, Single) 座標ペア、幅、および高さで指定され四角形描画ます。
参照参照

Graphics.DrawRectangle メソッド (Pen, Single, Single, Single, Single)

座標ペア、幅、および高さで指定され四角形描画ます。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub DrawRectangle ( _
    pen As Pen, _
    x As Single, _
    y As Single, _
    width As Single, _
    height As Single _
)
Dim instance As Graphics
Dim pen As Pen
Dim x As Single
Dim y As Single
Dim width As Single
Dim height As Single

instance.DrawRectangle(pen, x, y, width, height)
public void DrawRectangle (
    Pen pen,
    float x,
    float y,
    float width,
    float height
)
public:
void DrawRectangle (
    Pen^ pen, 
    float x, 
    float y, 
    float width, 
    float height
)
public void DrawRectangle (
    Pen pen, 
    float x, 
    float y, 
    float width, 
    float height
)
public function DrawRectangle (
    pen : Pen, 
    x : float, 
    y : float, 
    width : float, 
    height : float
)

パラメータ

pen

四角形の色、幅、およびスタイル決定する Pen

x

描画する四角形左上隅の x 座標

y

描画する四角形左上隅の y 座標

width

描画する四角形の幅。

height

描画する四角形の高さ。

例外例外
例外種類条件

ArgumentNullException

pennull 参照 (Visual Basic では Nothing) です。

使用例使用例

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

Public Sub DrawRectangleFloat(ByVal
 e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New
 Pen(Color.Black, 3)

    ' Create location and size of rectangle.
    Dim x As Single = 0.0F
    Dim y As Single = 0.0F
    Dim width As Single
 = 200.0F
    Dim height As Single
 = 200.0F

    ' Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, x, y, width, height)
End Sub
public void DrawRectangleFloat(PaintEventArgs
 e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create location and size of rectangle.
    float x = 0.0F;
    float y = 0.0F;
    float width = 200.0F;
    float height = 200.0F;
             
    // Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
}
public:
   void DrawRectangleFloat( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create location and size of rectangle.
      float x = 0.0F;
      float y = 0.0F;
      float width = 200.0F;
      float height = 200.0F;

      // Draw rectangle to screen.
      e->Graphics->DrawRectangle( blackPen, x, y, width, height );
   }
public void DrawRectangleFloat(PaintEventArgs
 e) 
{
    // Create pen.
    Pen blackPen =  new Pen(Color.get_Black(), 3);

    // Create location and size of rectangle.
    float x = 0;
    float y = 0;
    float width = 200;
    float height = 200;

    // Draw rectangle to screen.
    e.get_Graphics().DrawRectangle(blackPen, x, y, width, height);
} //DrawRectangleFloat
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Graphics.DrawRectangle メソッド (Pen, Int32, Int32, Int32, Int32)

座標ペア、幅、および高さで指定され四角形描画ます。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub DrawRectangle ( _
    pen As Pen, _
    x As Integer, _
    y As Integer, _
    width As Integer, _
    height As Integer _
)
Dim instance As Graphics
Dim pen As Pen
Dim x As Integer
Dim y As Integer
Dim width As Integer
Dim height As Integer

instance.DrawRectangle(pen, x, y, width, height)
public void DrawRectangle (
    Pen pen,
    int x,
    int y,
    int width,
    int height
)
public:
void DrawRectangle (
    Pen^ pen, 
    int x, 
    int y, 
    int width, 
    int height
)
public void DrawRectangle (
    Pen pen, 
    int x, 
    int y, 
    int width, 
    int height
)
public function DrawRectangle (
    pen : Pen, 
    x : int, 
    y : int, 
    width : int, 
    height : int
)

パラメータ

pen

四角形の色、幅、およびスタイル決定する Pen

x

描画する四角形左上隅の x 座標

y

描画する四角形左上隅の y 座標

width

描画する四角形の幅。

height

描画する四角形の高さ。

例外例外
例外種類条件

ArgumentNullException

pennull 参照 (Visual Basic では Nothing) です。

使用例使用例

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

Public Sub DrawRectangleInt(ByVal
 e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New
 Pen(Color.Black, 3)

    ' Create location and size of rectangle.
    Dim x As Integer = 0
    Dim y As Integer = 0
    Dim width As Integer
 = 200
    Dim height As Integer
 = 200

    ' Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, x, y, width, height)
End Sub
public void DrawRectangleInt(PaintEventArgs
 e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create location and size of rectangle.
    int x = 0;
    int y = 0;
    int width = 200;
    int height = 200;
             
    // Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
}
public:
   void DrawRectangleInt( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create location and size of rectangle.
      int x = 0;
      int y = 0;
      int width = 200;
      int height = 200;

      // Draw rectangle to screen.
      e->Graphics->DrawRectangle( blackPen, x, y, width, height );
   }
public void DrawRectangleInt(PaintEventArgs
 e) 
{
    // Create pen.
    Pen blackPen =  new Pen(Color.get_Black(), 3);

    // Create location and size of rectangle.
    int x = 0;
    int y = 0;
    int width = 200;
    int height = 200;

    // Draw rectangle to screen.
    e.get_Graphics().DrawRectangle(blackPen, x, y, width, height);
} //DrawRectangleInt
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からGraphics.DrawRectangleを検索した結果を表示しています。
Weblioに収録されているすべての辞書からGraphics.DrawRectangleを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からGraphics.DrawRectangleを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Graphics.DrawRectangle」の関連用語

Graphics.DrawRectangleのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Graphics.DrawRectangleのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS