Microsoft KB Archive/193399

= BUG: TabStrip Loses Selection When Placement Property is Changed =

Article ID: 193399

Article Last Modified on 5/13/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q193399



SYMPTOMS
When changing the Placement property of a TabStrip control (Placement determines the location of the tabs: top, bottom, right, left), the TabStrip may lose track of which Tab is selected. The selected Tab should not change when the Placement is changed.



RESOLUTION
The workaround for this problem is straightforward. Because the TabStrip may not retain the selected tab properly, you must do it programmatically. This value can be stored in a variable at the beginning of the procedure (or before changing the Placement property), and then restored at the end of the procedure (or after changing the Placement property). The following code will fix the problem as presented in step 7 of the Steps to Reproduce Behavior section of this article: Dim objSaveTab As Object With TabStrip1 Set objSaveTab = .SelectedItem If .Placement = 3 Then .Placement = 0 Else .Placement = TabStrip1.Placement + 1 End If     Set .SelectedItem = objSaveTab Debug.Print .SelectedItem End With



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a Standard EXE project in Visual Basic. Form1 is created default. Add the TabStrip component to the toolbox by selecting Components from the Project menu, checking "Microsoft Windows Common Controls 6.0," and then clicking OK. Add an instance of the TabStrip to Form1. Add a second tab to the TabStrip. Set the Caption property of Tab1 to "One" and the Caption of Tab2 to "Two." Add a CommandButton to Form1.</li>  Add the following code to Form1: Private Sub Command1_Click With TabStrip1 If .Placement = 3 Then .Placement = 0 Else .Placement = TabStrip1.Placement + 1 End If           Debug.Print .SelectedItem End With End Sub </li> Run the project and click on the tab labeled "Two."</li> Click the CommandButton twice and note that the selected tab (printed in the Immediate Window) changes from Two to One.</li></ol>

Additional query words: kbDSupport kbDSD kbVBp kbVBp600bug kbVBp kbCmnCtrls kbCtrl kbTabCtrl

Keywords: kbbug KB193399

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.