Previous | Index | Next 

[INFO] TabStrip and SSTab controls don’t display hotkeys in button captions

VB6’s TabStrip controls can react to hotkeys defined by assigning a string containing an ampersand (&) character to the Caption property of individual Tab objects. Similarly, you can define hotkeys for individual pages of an SSTab control by assigning a string containing an ampersand to the TabCaption property.

The TabStrip and the SSTab controls are converted to VB6TabStrip and VB6SSTab controls, respectively, both of which inherit from .NET TabControl. This control doesn’t offer the ability to process ampersands in individual tab captions; for this reason, individual ampersand characters are stripped off tab captions during the migration process. The end user isn’t allowed to switch to a different tab by means of Alt+key combination and can only cycle among tabs using the Ctrl+Tab key combination or the mouse.

There is no workaround for this issue. It is recommended that you drop all ampersands in SSTab and TabStrip captions before the migration, to have a consistent behavior both in VB6 and VB.NET.

On a related topic, notice that ampersand characters are stripped off both during the migration process and when you assign a tab caption via code, as in this code:

     SSTab1.TabCaption(1) = "&Options"

This behavior has a subtle consequence: if you later read back the TabCaption property, you’ll find the ampersand under VB6 but not in the converted VB.NET program:

        SSTab1.TabCaption(1) = "&Options"
        ' ...
        If SSTab1.TabCaption(1) = "&Options" Then
            ' this block is executed in VB6
        Else
            ' this block is executed under VB.NET, 
            ' because TabCaption(1) returns "Options"
        End If

You can work around this minor issue by slightly modifying the test, for example:

        If InStr(SSTab1.TabCaption(1), "Options") > 0 Then

 

Previous | Index | Next