ShapeCollection.GetChildIndex 方法 (Shape)
擷取指定的索引Shape在ShapeCollection。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
Public Function GetChildIndex ( _
child As Shape _
) As Integer
public int GetChildIndex(
Shape child
)
public:
int GetChildIndex(
Shape^ child
)
member GetChildIndex :
child:Shape -> int
public function GetChildIndex(
child : Shape
) : int
參數
- child
型別:Microsoft.VisualBasic.PowerPacks.Shape
要在 ShapeCollection 中搜尋的 Shape。
傳回值
型別:System.Int32
以零起始的索引值,表示指定的位置Shape在ShapeCollection。
例外狀況
例外狀況 | 條件 |
---|---|
ArgumentException | child圖形並不在ShapeCollection。 |
備註
索引表示形狀加入至集合的順序。如果要從集合移除形狀,會重新指派形狀的索引。
範例
下列範例會示範如何使用GetChildIndex方法,以擷取的位置Shape在ShapeCollection。這個範例要求您必須至少兩個OvalShape在表單上的控制項。
Private Sub OvalShape2_Click() Handles OvalShape2.Click
Dim i As Integer
' Find the index for OvalShape1.
i = OvalShape2.Parent.Shapes.GetChildIndex(OvalShape1)
MsgBox("The index for OvalShape1 is " & CStr(i))
End Sub
private void ovalShape2_Click(System.Object sender, System.EventArgs e)
{
int i;
String index;
// Find the index for OvalShape1.
i = ovalShape2.Parent.Shapes.GetChildIndex(ovalShape1);
index = i.ToString();
MessageBox.Show("The index for OvalShape1 is " + index);
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
Line 和 Shape 控制項簡介 (Visual Studio)
HOW TO:使用 LineShape 控制項繪製線條 (Visual Studio)
HOW TO:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)