This documentation is archived and is not being maintained.

How to: Enable Tabbing Between Shapes (Visual Studio)

Updated: July 2008

Line and shape controls do not have TabStop or TabIndex properties, but you can still enable tabbing among them. In the following example, pressing both the CTRL and the TAB keys will tab between shapes; pressing only the TAB key will tab between the buttons.


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 or using statement at the top of the module:

    Imports Microsoft.VisualBasic.PowerPacks

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

    private void shapes_PreviewKeyDown(Shape sender, System.Windows.Forms.PreviewKeyDownEventArgs e)
        Shape sh;
        // Check for the Control and Tab keys. 
        if (e.KeyCode == Keys.Tab && e.Modifiers == Keys.Control)
        // Find the next shape in the order.
            sh = shapeContainer1.GetNextShape(sender, true);
            // Select the next shape.
            shapeContainer1.SelectNextShape(sender, false, true);
  4. Add the following code in the Button1_PreviewKeyDown event procedure:

    private void button1_PreviewKeyDown(object sender, System.Windows.Forms.PreviewKeyDownEventArgs e)
        // Check for the Control and Tab keys. 
        if (e.KeyCode == Keys.Tab & e.Modifiers == Keys.Control)
        // Select the first shape.




July 2008

Added topic.

SP1 feature change.