Compartir a través de


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

'Declaration
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

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 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 Security

See Also

Reference

ShapeCollection Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

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)