ShapeCollection.AddRange (Método)
Agrega una matriz de objetos Shape al ShapeCollection.
Espacio de nombres: Microsoft.VisualBasic.PowerPacks
Ensamblado: Microsoft.VisualBasic.PowerPacks.Vs (en Microsoft.VisualBasic.PowerPacks.Vs.dll)
Sintaxis
'Declaración
Public Sub AddRange ( _
shapes As Shape() _
)
public void AddRange(
Shape[] shapes
)
public:
void AddRange(
array<Shape^>^ shapes
)
member AddRange :
shapes:Shape[] -> unit
public function AddRange(
shapes : Shape[]
)
Parámetros
shapes
Tipo: array<Microsoft.VisualBasic.PowerPacks.Shape[]Matriz de objetos Shape que se agregará a la colección.
Comentarios
Los objetos de Shape incluidos en la matriz de shapes se agregan al final de la colección.
Puede utilizar el método de AddRange para agregar rápidamente a un grupo de objetos de Shape a la colección. Esto es más rápido que manualmente agregando cada Shape a la colección mediante el método de Add .
Para quitar Shape agregado, utiliza previamente Remove, RemoveAt, o un método de Clear .
Notas para los herederos
Al reemplazar AddRange en una clase derivada, asegúrese de llamar al método de AddRange de la clase base para garantizar que las formas se agregan a la colección.
Ejemplos
El ejemplo siguiente se agrega un grupo de controles de OvalShape a ShapeCollection de un formulario. El ejemplo requiere tener un control de RectangleShape en un formulario.
Private Sub RectangleShape1_Click() Handles RectangleShape1.Click
' Create two oval shapes to add to the form.
Dim oval1 As OvalShape = New OvalShape()
Dim oval2 As OvalShape = New OvalShape()
' Set the size of the ovals.
oval1.Size = New Size(100, 200)
oval2.Size = oval1.Size
' Set the appropriate location of ovals.
oval1.Location = New Point(10, 10)
oval2.Location = New Point(oval1.Left + 10, oval1.Top + 10)
' Add the controls to the form by using the AddRange method.
RectangleShape1.Parent.Shapes.AddRange(New Shape() {oval1, oval2})
End Sub
private void rectangleShape1_Click(System.Object sender, System.EventArgs e)
{
// Create two oval shapes to add to the form.
OvalShape oval1 = new OvalShape();
OvalShape oval2 = new OvalShape();
// Set the size of the ovals.
oval1.Size = new Size(100, 200);
oval2.Size = oval1.Size;
// Set the appropriate location of ovals.
oval1.Location = new Point(10, 10);
oval2.Location = new Point(oval1.Left + 10, oval1.Top + 10);
// Add the controls to the form by using the AddRange method.
rectangleShape1.Parent.Shapes.AddRange(new Shape[] { oval1, oval2 });
}
Seguridad de .NET Framework
- Plena confianza para el llamador inmediato. Un código de confianza parcial no puede utilizar este miembro. Para obtener más información, vea Utilizar bibliotecas de código que no es de plena confianza.
Vea también
Referencia
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)