ShapeCollection.Remove 方法
將指定的 Shape 從 ShapeCollection 移除。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
Public Sub Remove ( _
value As Shape _
)
public void Remove(
Shape value
)
public:
void Remove(
Shape^ value
)
member Remove :
value:Shape -> unit
public function Remove(
value : Shape
)
參數
value
類型:Microsoft.VisualBasic.PowerPacks.Shape要從 ShapeCollection 移除的 Shape。
備註
當 Shape 控制項從集合中移除時,後續的所有圖案都會在集合中上移一個位置。
使用 RemoveAt 方法,您也可以移除 Shape ,使用 Clear 方法,或是移除所有的形狀。
將新的 Shape 物件加入集合,請使用 Add 或 AddRange 方法。
繼承者注意事項
覆寫衍生類別中 Remove ,請確定呼叫基底類別的 Remove 以確保形狀已從集合中移除。
範例
如果是表單之 ShapeCollection的成員,下列範例示範如何使用 Remove 方法從表單中移除 Shape 。 這個範例要求您的表單上必須有至少兩個 OvalShape 控制項。
Private Sub Form1_Click() Handles Me.Click
Dim canvas As ShapeContainer
' Get the ShapeContainer.
canvas = OvalShape1.Parent
' If OvalShape2 is in the same collection, remove it.
If canvas.Shapes.Contains(OvalShape2) Then
canvas.Shapes.Remove(OvalShape2)
End If
End Sub
private void form1_Click(object sender, System.EventArgs e)
{
ShapeContainer canvas;
// Get the ShapeContainer.
canvas = ovalShape1.Parent;
// If OvalShape2 is in the same collection, remove it.
if (canvas.Shapes.Contains(ovalShape2))
{
canvas.Shapes.Remove(ovalShape2);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
Line 和 Shape 控制項簡介 (Visual Studio)