共用方式為


ShapeContainer.GetNextShape 方法

ShapeCollection 的順序擷取下一個或上一個圖形。

命名空間:  Microsoft.VisualBasic.PowerPacks
組件:  Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

語法

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

參數

  • forward
    類型:Boolean

    true 表示要向前搜尋,false 表示要向後搜尋。

傳回值

類型:Microsoft.VisualBasic.PowerPacks.Shape
ShapeCollection 順序中的下一個 Shape

備註

圖案加入至 ShapeCollection的命令取決於初始命令;您可以藉由呼叫 SetChildIndex 方法來變更命令。

範例

下列範例示範如何使用 GetNextShape 和 SelectNextShape 方法使用 TAB 鍵在表單的形狀間移動。 這個範例要求您的表單上必須有至少三個 RectangleShape 控制項。

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

其他資源

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

如何:使用 LineShape 控制項繪製線條 (Visual Studio)

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