共用方式為


ShapeCollection.GetChildIndex 方法 (Shape)

擷取指定的索引ShapeShapeCollection

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

參數

傳回值

型別:System.Int32
以零起始的索引值,表示指定的位置ShapeShapeCollection

例外狀況

例外狀況 條件
ArgumentException

child圖形並不在ShapeCollection

備註

索引表示形狀加入至集合的順序。如果要從集合移除形狀,會重新指派形狀的索引。

範例

下列範例會示範如何使用GetChildIndex方法,以擷取的位置ShapeShapeCollection。這個範例要求您必須至少兩個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 安全性

請參閱

參考

ShapeCollection 類別

GetChildIndex 多載

Microsoft.VisualBasic.PowerPacks 命名空間

IndexOf

其他資源

Line 和 Shape 控制項簡介 (Visual Studio)

HOW TO:使用 LineShape 控制項繪製線條 (Visual Studio)

HOW TO:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)