ShapeCollection.AddRange 方法

添加数组到 ShapeCollectionShape 对象。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
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[]
)

参数

备注

在 shapes 数组包含的 Shape 对象添加到集合的末尾。

可以使用 AddRange 方法快速添加 Shape 对象的一组至的集合。这比手动添加每 Shape 快速到集合使用 Add 方法。

移除先前,使用 RemoveRemoveAtClear 方法的 Shape

对继承者的说明

当重写在派生类中 AddRange ,请务必调用基类的 AddRange 方法确保形状添加到集合中。

示例

下面的示例将 OvalShape 一组控件添加到窗体的 ShapeCollection 。该示例要求窗体的一个 RectangleShape 控件。

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 });
}

.NET Framework 安全性

请参见

参考

ShapeCollection 类

Microsoft.VisualBasic.PowerPacks 命名空间

其他资源

Line 和 Shape 控件简介 (Visual Studio)

如何:使用 LineShape 控件绘制直线 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控件绘制形状 (Visual Studio)