ShapeCollection.GetChildIndex Method (Shape)
Retrieves the index of the specified Shape in the ShapeCollection.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'Declaration
Public Function GetChildIndex ( _
child As Shape _
) As Integer
public int GetChildIndex(
Shape child
)
public:
int GetChildIndex(
Shape^ child
)
member GetChildIndex :
child:Shape -> int
public function GetChildIndex(
child : Shape
) : int
Parameters
child
Type: Microsoft.VisualBasic.PowerPacks.ShapeThe Shape to search for in the ShapeCollection.
Return Value
Type: Int32
A zero-based index value that represents the location of the specified Shape in the ShapeCollection.
Exceptions
Exception | Condition |
---|---|
ArgumentException | The child shape is not in the ShapeCollection. |
Remarks
The index represents the order in which the shapes were added to the collection. If shapes are removed from the collection, the indexes of the shapes are reassigned.
Examples
The following example demonstrates how to use the GetChildIndex method to retrieve the location of a Shape in a ShapeCollection. This example requires that you have at least two OvalShape controls on a form.
Private Sub OvalShape2_Click() Handles OvalShape2.Click
Dim i As Integer
' Find the index for OvalShape1.
i = OvalShape2.Parent.Shapes.GetChildIndex(OvalShape1)
MsgBox("The index for OvalShape1 is " & CStr(i))
End Sub
private void ovalShape2_Click(System.Object sender, System.EventArgs e)
{
int i;
String index;
// Find the index for OvalShape1.
i = ovalShape2.Parent.Shapes.GetChildIndex(ovalShape1);
index = i.ToString();
MessageBox.Show("The index for OvalShape1 is " + index);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
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)