Método ShapeCollection.SetChildIndex
Define o índice especificado Shape na ShapeCollection o valor de índice especificado.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (em Microsoft.VisualBasic.PowerPacks.Vs.dll)
Sintaxe
'Declaração
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
- child
Tipo: Microsoft.VisualBasic.PowerPacks.Shape
O Shape para pesquisar.
- newIndex
Tipo: System.Int32
O valor de índice de novo a Shape.
Exceções
Exceção | Condição |
---|---|
ArgumentException | O child forma não estiver a ShapeCollection. |
Comentários
Quando SetChildIndex é chamado, o Shape nomeada de acordo com o child parâmetro é movido para a posição especificada pelo newIndex.O outro Shape referencia na ShapeCollection são reordenadas para permitir a movimentação.
Exemplos
O exemplo a seguir demonstra como usar o SetChildIndex método para alterar o índice de um Shape em um ShapeCollection.Este exemplo requer que você tenha pelo menos duas OvalShape controles em um formulário.
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);
}
}
Segurança do .NET Framework
- Confiança total para o chamador imediato. O membro não pode ser usado por código parcialmente confiável. Para obter mais informações, consulte Usando bibliotecas de código parcialmente confiáveis.
Consulte também
Referência
Namespace Microsoft.VisualBasic.PowerPacks
Outros recursos
Introdução à linha e controles Shape (Visual Studio)
Como: desenhar linhas com o controle de LineShape (Visual Studio)
Como: desenhar formas com os controles de RectangleShape (Visual Studio) e o OvalShape