Compartir a través de


ShapeCollection.Add (Método)

Agrega el objeto Shape especificado a la colección ShapeCollection.

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

Sintaxis

'Declaración
Public Sub Add ( _
    value As Shape _
)
public void Add(
    Shape value
)
public:
void Add(
    Shape^ value
)
member Add : 
        value:Shape -> unit
public function Add(
    value : Shape
)

Parámetros

Comentarios

El método de Add permite agregar objetos de Shape al final de ShapeCollection.

También se pueden agregar nuevos objetos Shape a la colección utilizando el método AddRange.

Para quitar Shape agregado, utiliza previamente Remove, RemoveAt, o un método de Clear .

Notas para los herederos

Al reemplazar Add en una clase derivada, asegúrese de llamar al método de Add de la clase base para garantizar que Shape se agrega a ShapeCollection.

Ejemplos

El ejemplo siguiente agrega nuevo Shape a ShapeCollection de un formulario. Este ejemplo requiere tener un control de RectangleShape en un formulario.

Private Sub RectangleShape1_Click() Handles RectangleShape1.Click
    ' Declare a new oval shape to add to the form. 
    Dim oval As OvalShape = New OvalShape()
    ' Add the oval shape to the form.
    RectangleShape1.Parent.Shapes.Add(oval)
    oval.Location = New Point(50, 50)
    oval.Size = New Size(200, 100)
End Sub
private void rectangleShape1_Click(System.Object sender, System.EventArgs e)
{
    // Declare a new oval shape to add to the form.
    OvalShape oval = new OvalShape();
    // Add the oval shape to the form.
    rectangleShape1.Parent.Shapes.Add(oval);
    oval.Location = new Point(50, 50);
    oval.Size = new Size(200, 100);
}

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)