Compartir a través de


ShapeCollection.SetChildIndex (Método)

Establece del Shape especificado en ShapeCollection en el valor del índice especificado.

Espacio de nombres:  Microsoft.VisualBasic.PowerPacks
Ensamblado:  Microsoft.VisualBasic.PowerPacks.Vs (en Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintaxis

'Declaración
Public Sub SetChildIndex ( _
    child As Shape, _
    newIndex As Integer _
)
public void SetChildIndex(
    Shape child,
    int newIndex
)
public:
void SetChildIndex(
    Shape^ child, 
    int newIndex
)
member SetChildIndex : 
        child:Shape * 
        newIndex:int -> unit
public function SetChildIndex(
    child : Shape, 
    newIndex : int
)

Parámetros

  • newIndex
    Tipo: Int32

    Valor nuevo del índice del Shape.

Excepciones

Excepción Condición
ArgumentException

La forma child no está en ShapeCollection.

Comentarios

Cuando se llama a SetChildIndex , Shape al que hace referencia el parámetro de child se mueve a la posición especificada por newIndex. Las otras referencias de Shape en ShapeCollection se reordenan para permitir el movimiento.

Ejemplos

El ejemplo siguiente muestra cómo utilizar el método de SetChildIndex para cambiar el índice de Shape en ShapeCollection. Este ejemplo requiere que tenga al menos dos controles de OvalShape en un formulario.

Private Sub OvalShape1_Click() Handles OvalShape1.Click
    Dim i As Integer 
    ' Find the index for OvalShape2.
    i = OvalShape1.Parent.Shapes.GetChildIndex(OvalShape2, False)
    ' If the shape is not in the collection, display a message. 
    If i = -1 Then
        MsgBox("OvalShape2 is not in this collection.")
    Else 
        ' Change the index to 0.
        OvalShape1.Parent.Shapes.SetChildIndex(OvalShape2, 0)
    End If 
End Sub
private void ovalShape1_Click(System.Object sender, System.EventArgs e)
{
    int i;
    // Find the index for OvalShape2.
    i = ovalShape1.Parent.Shapes.GetChildIndex(ovalShape2, false);
    // If the shape is not in the collection, display a message. 
    if (i == -1)
    {
        MessageBox.Show("ovalShape2 is not in this collection.");
    }
    else
    {
        // Change the index to 0.
        ovalShape1.Parent.Shapes.SetChildIndex(ovalShape2, 0);
    }
}

Seguridad de .NET Framework

Vea también

Referencia

ShapeCollection Clase

Microsoft.VisualBasic.PowerPacks (Espacio de nombres)

Otros recursos

Introducción a los controles de líneas y formas (Visual Studio)

Cómo: Dibujar líneas con el control LineShape (Visual Studio)

Cómo: Dibujar formas con los controles OvalShape y RectangleShape (Visual Studio)