次の方法で共有


RectangleShape コンストラクター

RectangleShape クラスの新しいインスタンスを初期化します。

名前空間:  Microsoft.VisualBasic.PowerPacks
アセンブリ:  Microsoft.VisualBasic.PowerPacks.Vs (Microsoft.VisualBasic.PowerPacks.Vs.dll 内)

構文

'宣言
Public Sub New
public RectangleShape()
public:
RectangleShape()
new : unit -> RectangleShape
public function RectangleShape()

解説

RectangleShape のコントロールをフォームまたはコンテナー コントロールに直接表示できません; これは ShapeContainer オブジェクトに含まれている必要があります。 RectangleShapeを初期化した後、既存の ShapeContainer または ShapeContainerの新しいインスタンスに Parent のプロパティを設定する必要があります。

次の例では ShapeContainerRectangleShapeを作成し、フォームに追加し、四角形を表示します。

Private Sub DrawRectangle()
    Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
    Dim rect1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape
    ' Set the form as the parent of the ShapeContainer.
    canvas.Parent = Me 
    ' Set the ShapeContainer as the parent of the RectangleShape.
    rect1.Parent = canvas
    ' Set the location and size of the rectangle.
    rect1.Left = 10
    rect1.Top = 10
    rect1.Width = 300
    rect1.Height = 100
End Sub
private void DrawRectangle()
{
    Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas = 
        new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
    Microsoft.VisualBasic.PowerPacks.RectangleShape rect1 = 
        new Microsoft.VisualBasic.PowerPacks.RectangleShape();
    // Set the form as the parent of the ShapeContainer.
    canvas.Parent = this;
    // Set the ShapeContainer as the parent of the RectangleShape.
    rect1.Parent = canvas;
    // Set the location and size of the rectangle.
    rect1.Left = 10;
    rect1.Top = 10;
    rect1.Width = 300;
    rect1.Height = 100;
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

RectangleShape クラス

RectangleShape オーバーロード

Microsoft.VisualBasic.PowerPacks 名前空間

その他の技術情報

ライン コントロールとシェイプ コントロールの概要 (Visual Studio)

方法 : LineShape コントロールを使用して線を描画する (Visual Studio)

方法 : OvalShape コントロールおよび RectangleShape コントロールを使用して図形を描画する (Visual Studio)