次の方法で共有


ShapeContainer.SelectNextShape メソッド

ShapeCollection の順序で次または前の図形を選択します。

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

構文

'宣言
Public Function SelectNextShape ( _
    shape As Shape, _
    forward As Boolean, _
    wrap As Boolean _
) As Boolean
public bool SelectNextShape(
    Shape shape,
    bool forward,
    bool wrap
)
public:
bool SelectNextShape(
    Shape^ shape, 
    bool forward, 
    bool wrap
)
member SelectNextShape : 
        shape:Shape * 
        forward:bool * 
        wrap:bool -> bool 
public function SelectNextShape(
    shape : Shape, 
    forward : boolean, 
    wrap : boolean
) : boolean

パラメーター

  • forward
    型 : System.Boolean
    順序で前方に移動する true ; 後方に false。
  • wrap
    型 : System.Boolean
    最後の図形の後に順序で最初の図形から検索し続ける true に達するまで ; それ以外 false。

戻り値

型 : System.Boolean
図形が有効な場合 true ; それ以外 false。

解説

初回の順序は、図形が ShapeCollection に追加する順序によって決まります ; SetChildIndex のメソッドを呼び出して、順序を変更できます。

次の例では、フォームの形状で移動するには、Tab キーを使用するに SelectNextShape の GetNextShape メソッドおよびメソッドの使用方法を示します。この例では、フォームの少なくとも RectangleShape の 3 種類のコントロールがあることが必要です。

Private Sub Shapes_PreviewKeyDown(
    ByVal sender As Object, 
    ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs
  ) Handles RectangleShape1.PreviewKeyDown, 
            RectangleShape2.PreviewKeyDown, 
            RectangleShape3.PreviewKeyDown

    Dim sh As Shape
    ' Check for the TAB key.
    If e.KeyCode = Keys.Tab Then
        ' Find the next shape in the order.
        sh = ShapeContainer1.GetNextShape(sender, True)
        ' Select the next shape.
        ShapeContainer1.SelectNextShape(sender, True, True)
    End If
End Sub
private void Shapes_PreviewKeyDown(object sender, 
    System.Windows.Forms.PreviewKeyDownEventArgs e)
{
    Shape sh;
    // Check for the TAB key.
    if (e.KeyCode==Keys.Tab)
        // Find the next shape in the order.
    {
        sh = shapeContainer1.GetNextShape((Shape) sender, true);
        // Select the next shape.
        shapeContainer1.SelectNextShape((Shape) sender, true, true);
    }
}

.NET Framework セキュリティ

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

参照

関連項目

ShapeContainer クラス

Microsoft.VisualBasic.PowerPacks 名前空間

その他の技術情報

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

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

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