ShapeContainer.SelectNextShape Method

Selects 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

'Declaração
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

Parameters

  • forward
    Type: System.Boolean
    true to move forward in the order; false to move backward.
  • wrap
    Type: System.Boolean
    true to continue searching from the first shape in the order after the last shape is reached; otherwise, false.

Return Value

Type: System.Boolean
true if a shape was enabled; otherwise, false.

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)