次の方法で共有


ShapeCollection.SetChildIndex メソッド

ShapeCollection の指定した Shape のインデックスを指定したインデックス値に設定します。

名前空間:  Microsoft.VisualBasic.PowerPacks
アセンブリ:  Microsoft.VisualBasic.PowerPacks.Vs (Microsoft.VisualBasic.PowerPacks.Vs.dll 内)

構文

'宣言
Public Sub SetChildIndex ( _
    child As Shape, _
    newIndex As Integer _
)
public void SetChildIndex(
    Shape child,
    int newIndex
)
public:
void SetChildIndex(
    Shape^ child, 
    int newIndex
)
member SetChildIndex : 
        child:Shape * 
        newIndex:int -> unit
public function SetChildIndex(
    child : Shape, 
    newIndex : int
)

パラメーター

  • newIndex
    型 : Int32

    Shape の新しいインデックス値。

例外

例外 条件
ArgumentException

child 図形は、ShapeCollection にはありません。

解説

SetChildIndex が呼び出されると、child パラメーターによって参照される Shape は newIndexで指定した位置に移動します。 ShapeCollectionShape の他の参照は移動を有効にするように順序を変更します。

次の例に ShapeCollectionShape のインデックスを変更するには SetChildIndex のメソッドを使用する方法を示します。 この例では、フォームの少なくとも OvalShape の 2 種類のコントロールが必要です。

Private Sub OvalShape1_Click() Handles OvalShape1.Click
    Dim i As Integer 
    ' Find the index for OvalShape2.
    i = OvalShape1.Parent.Shapes.GetChildIndex(OvalShape2, False)
    ' If the shape is not in the collection, display a message. 
    If i = -1 Then
        MsgBox("OvalShape2 is not in this collection.")
    Else 
        ' Change the index to 0.
        OvalShape1.Parent.Shapes.SetChildIndex(OvalShape2, 0)
    End If 
End Sub
private void ovalShape1_Click(System.Object sender, System.EventArgs e)
{
    int i;
    // Find the index for OvalShape2.
    i = ovalShape1.Parent.Shapes.GetChildIndex(ovalShape2, false);
    // If the shape is not in the collection, display a message. 
    if (i == -1)
    {
        MessageBox.Show("ovalShape2 is not in this collection.");
    }
    else
    {
        // Change the index to 0.
        ovalShape1.Parent.Shapes.SetChildIndex(ovalShape2, 0);
    }
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

ShapeCollection クラス

Microsoft.VisualBasic.PowerPacks 名前空間

その他の技術情報

ライン コントロールとシェイプ コントロールの概要 (Visual Studio)

方法 : LineShape コントロールを使用して線を描画する (Visual Studio)

方法 : OvalShape コントロールおよび RectangleShape コントロールを使用して図形を描画する (Visual Studio)