Share via


ShapeCollection.Item Property (Int32)

 

Gets the Shape at the specified indexed location in the collection.

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

Syntax

public object this[
    int index
] { get; set; }
public:
property Object^ default[
    int index
] {
    virtual Object^ get(int index) sealed;
    virtual void set(int index, Object^ value) sealed;
}
abstract Item : 
        index:int -> Object with get, set
override Item : 
        index:int -> Object with get, set
Public Property Item (
    index As Integer
) As Object

Parameters

Property Value

Type: System.Object

The Shape located at the specified index location in the ShapeCollection.

Implements

IList.Item[Int32]

Remarks

To retrieve a Shape from the ShapeCollection, reference the collection object by using a specific index value. The index value of the ShapeCollection is a zero-based index.

Examples

The following example uses the Index of a ShapeCollection to set the focus to a shape. This example requires that you have a Button, a LineShape, an OvalShape, and a RectangleShape control on a form.

private void button1_Click(System.Object sender, System.EventArgs e)
{
    // Set the focus to the first shape (index 0).
    Shape selectedShape = ((Shape) shapeContainer1.Shapes.get_Item(0));
    selectedShape.Focus();
}
Private Sub Button1_Click() Handles Button1.Click
    ' Set the focus to the first shape (index 0).
    ShapeContainer1.Shapes.Item(0).Focus()
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