ShapeCollection.RemoveAt 方法
从 ShapeCollection 移除 Shape 在指定的索引位置。
命名空间: Microsoft.VisualBasic.PowerPacks
程序集: Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
语法
声明
Public Sub RemoveAt ( _
index As Integer _
)
public void RemoveAt(
int index
)
public:
virtual void RemoveAt(
int index
) sealed
abstract RemoveAt :
index:int -> unit
override RemoveAt :
index:int -> unit
public final function RemoveAt(
index : int
)
参数
- index
类型:System.Int32
要移除的 Shape 的索引值。
实现
备注
当 Shape 从控件集合中移除,所有后续形状中移动集合中的某个位置。
使用 Remove 方法,还可以移除 Shape ,使用 Clear 方法,也可以移除所有形状。
若要向集合中添加新的 Shape 对象,请使用 Add 或 AddRange 方法。
示例
,如果它是窗体的 ShapeCollection,的成员下面的示例演示如何使用 RemoveAt 方法从窗体中移除 Shape 。 此示例要求窗体的至少有两个 OvalShape 控件。
Private Sub OvalShape2_Click() Handles OvalShape2.Click
Dim i As Integer
' Find the index for OvalShape1.
i = OvalShape2.Parent.Shapes.GetChildIndex(OvalShape1, False)
' If the shape is not in the collection, display a message.
If i = -1 Then
MsgBox("OvalShape1 is not in this collection.")
Else
' Remove the shape.
OvalShape2.Parent.Shapes.RemoveAt(i)
End If
End Sub
private void ovalShape2_Click(System.Object sender, System.EventArgs e)
{
int i;
// Find the index for OvalShape1.
i = ovalShape2.Parent.Shapes.GetChildIndex(ovalShape1, false);
// If the shape is not in the collection, display a message.
if (i == -1)
{
MessageBox.Show("ovalShape1 is not in this collection.");
}
else
{
// Remove the shape.
ovalShape2.Parent.Shapes.RemoveAt(i);
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualBasic.PowerPacks 命名空间
其他资源
Line 和 Shape 控件简介 (Visual Studio)