Export (0) Print
Expand All

How to: Enable Tabbing Between Shapes

Visual Studio 2005

Line and shape controls do not have TabStop or TabIndex properties, but you can still enable tabbing among them.

Note:

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To enable tabbing among shapes

  1. Drag three RectangleShape controls and two Button controls from the Toolbox to a form.

  2. In the Code Editor, add an Imports statement at the top of the module:

    Imports Microsoft.VisualBasic.PowerPacks
    
  3. Add the following code in an event procedure:

    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 Control and Tab keys.
        If e.KeyCode = Keys.Tab And e.Modifiers = Keys.Control Then
            ' Find the next shape in the order.
            sh = ShapeContainer1.GetNextShape(sender, True)
            ' Select the next shape.
            ShapeContainer1.SelectNextShape(sender, False, True)
        End If
    End Sub
    
  4. Add the following code in the Button1_PreviewKeyDown event procedure:

    Private Sub Button1_PreviewKeyDown(ByVal sender As Object, _
      ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) _
      Handles Button1.PreviewKeyDown
            ' Check for the Control and Tab keys.
            If e.KeyCode = Keys.Tab And e.Modifiers = Keys.Control Then
                ' Select the first shape.
                RectangleShape1.Select()
            End If
        End Sub
    

Community Additions

ADD
Show:
© 2014 Microsoft