ShapeContainer.GetNextShape Method (Shape, Boolean)
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
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 As Shape,
forward As Boolean
) As Shape
Parameters
shape
Type: Microsoft.VisualBasic.PowerPacks.ShapeThe Shape to start the search with.
forward
Type: System.Booleantrue 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 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);
}
}
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
See Also
ShapeContainer Class
Microsoft.VisualBasic.PowerPacks Namespace
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)
Return to top