ShapeCollection.RemoveAt Method
Removes a Shape from the ShapeCollection at the specified indexed location.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'Declaration
Public Sub RemoveAt ( _
index As Integer _
)
public void RemoveAt(
int index
)
public:
virtual void RemoveAt(
int index
) sealed
abstract RemoveAt :
index:int -> unit
override RemoveAt :
index:int -> unit
public final function RemoveAt(
index : int
)
Parameters
index
Type: System.Int32The index value of the Shape to remove.
Implements
Remarks
When a Shape is removed from the control collection, all subsequent shapes are moved up one position in the collection.
You can also remove a Shape by using the Remove method, or remove all shapes by using the Clear method.
To add new Shape objects to the collection, use the Add or AddRange method.
Examples
The following example demonstrates how to use the RemoveAt method to remove a Shape from a form if it is a member of the form's 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, False)
' If the shape is not in the collection, display a message.
If i = -1 Then
MsgBox("OvalShape1 is not in this collection.")
Else
' Remove the shape.
OvalShape2.Parent.Shapes.RemoveAt(i)
End If
End Sub
private void ovalShape2_Click(System.Object sender, System.EventArgs e)
{
int i;
// Find the index for OvalShape1.
i = ovalShape2.Parent.Shapes.GetChildIndex(ovalShape1, false);
// If the shape is not in the collection, display a message.
if (i == -1)
{
MessageBox.Show("ovalShape1 is not in this collection.");
}
else
{
// Remove the shape.
ovalShape2.Parent.Shapes.RemoveAt(i);
}
}
.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)