ShapeCollection.AddRange 方法
將 Shape 物件陣列加入 ShapeCollection 中。
命名空間: 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
類型:array<Microsoft.VisualBasic.PowerPacks.Shape[]要加入至集合中之 Shape 物件的陣列。
備註
在 shapes 陣列中的 Shape 物件加入至集合的結尾。
您可以使用 AddRangeShape 方法快速地將一組物件加入至集合的。 這比手動將每個 Shape 快速加入集合可以使用 Add 方法。
移除先前加入的,請使用 Remove、 RemoveAt或 Clear 方法的 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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
Line 和 Shape 控制項簡介 (Visual Studio)