次の方法で共有


ShapeCollection.Count プロパティ

コレクション内の図形の数を取得します。

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

構文

'宣言
Public ReadOnly Property Count As Integer
public int Count { get; }
public:
virtual property int Count {
    int get () sealed;
}
abstract Count : int with get 
override Count : int with get
final function get Count () : int

プロパティ値

型 : Int32
コレクション内の図形の数を表す Integer。

実装

ICollection.Count

解説

Count の図形を ShapeCollectionプロパティが何であるかを判断するために使用できます。 また、For…Next のステートメントのコレクションを反復処理するために使用できます。

Count プロパティを使用する例を次に示します。 この例では、フォームの LineShapeOvalShapeRectangleShape のコントロールが必要です。

Private Sub Shapes_Click(
  ) Handles RectangleShape1.Click, 
            OvalShape1.Click, LineShape1.Click
    Dim i As Integer = ShapeContainer1.Shapes.Count
    MsgBox("There are " & CStr(i) & " shapes in the collection.")
End Sub
private void Shapes_Click(System.Object sender, System.EventArgs e)
{
    int i = shapeContainer1.Shapes.Count;
    Console.WriteLine("There are {0} shapes in the collection.", i);
}

.NET Framework セキュリティ

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

参照

関連項目

ShapeCollection クラス

Microsoft.VisualBasic.PowerPacks 名前空間

その他の技術情報

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

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

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