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
'Declaration
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
shape
Type: Microsoft.VisualBasic.PowerPacks.ShapeThe Shape to start the search with.
forward
Type: Booleantrue to move forward in the order; false to move backward.
wrap
Type: Booleantrue to continue searching from the first shape in the order after the last shape is reached; otherwise, false.
Return Value
Type: 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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
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)