Share via


ShapeCollection.Count Property

 

Gets the number of shapes in the collection.

Namespace:   Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

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

Property Value

Type: System.Int32

An Integer representing the number of shapes in the collection.

Implements

ICollection.Count

Remarks

The Count property can be used to determine how many shapes are in the ShapeCollection. It can also be used to iterate through the collection in a For…Next statement.

Examples

The following example demonstrates the use of the Count property. This example requires that you have a LineShape, an OvalShape, and a RectangleShape control on a form.

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);
}
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

See Also

ShapeCollection Class
Microsoft.VisualBasic.PowerPacks Namespace
Introduction to the Line and Shape Controls (Visual Studio)
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Return to top