ShapeCollection.Remove 方法

ShapeCollection 中移除指定的 Shape

命名空间:  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
)

参数

备注

Shape 从控件集合中移除,所有后续形状中移动集合中的某个位置。

使用 RemoveAt 方法,还可以移除 Shape ,使用 Clear 方法,也可以移除所有形状。

若要向集合中添加新的 Shape 对象,请使用 AddAddRange 方法。

对继承者的说明

当重写在派生类中 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 安全性

请参见

参考

ShapeCollection 类

Microsoft.VisualBasic.PowerPacks 命名空间

其他资源

Line 和 Shape 控件简介 (Visual Studio)

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

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