Compartir a través de


ShapeContainer.GetNextShape Method

Retrieves the next or previous shape in the order of the ShapeCollection.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaration
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

Parameters

  • forward
    Type: System.Boolean

    true to search forward; false to search backward.

Return Value

Type: Microsoft.VisualBasic.PowerPacks.Shape
The next Shape in the order of the ShapeCollection.

Remarks

The initial order is determined by the order in which shapes are added to the ShapeCollection; you can change the order by calling the SetChildIndex method.

Examples

The following example demonstrates how to use the GetNextShape and SelectNextShape methods to use the TAB key to move through the shapes on a form. This example requires that you have at least three RectangleShape controls on a form.

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 Security

See Also

Reference

ShapeContainer Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

Introduction to the Line and Shape Controls (Visual Studio)

How to: Draw Lines with the LineShape Control (Visual Studio)

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)