共用方式為


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 命名空間

其他資源

Line 和 Shape 控制項簡介 (Visual Studio)

如何:使用 LineShape 控制項繪製線條 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)