Microsoft KB Archive/905721

= The text on a TabControl control may not be displayed in the .NET Framework 1.1 =

Article ID: 905721

Article Last Modified on 5/21/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1

-





SYMPTOMS
In the Microsoft .NET Framework 1.1, the text on a TabControl control may not be displayed when the following conditions are true:
 * You use a Windows Forms application.
 * You use a TabControl control in the application.
 * You try to align the TabControl control on the left or on the right.
 * You enable visual styles for the application by using the EnableVisualStyles method.



CAUSE
This behavior occurs because of a limitation of the TabControl control in Microsoft Common Control 6.0.



WORKAROUND
To work around this behavior, use one of the following methods.

Method 1
Disable visual styles for the application by removing the call to the EnableVisualStyles method.

Method 2
Set the DrawMode property of the TabControl control to the OwnerDrawFixed value. Additionally, add custom code to draw the tabs. For more information, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.tabcontrol.drawmode(vs.71).aspx



Steps to reproduce the behavior
 Start Microsoft Visual Studio .NET 2003. Use Microsoft Visual Basic .NET 2003 to create a Windows Forms application. Name the application myTabControl, and then click OK. Add a TabControl control to Form1. In the designer for Form1, right-click the TabControl control, and then click Add Tab. Perform step 4 three times to add three tabs on the TabControl control. In Solution Explorer, right-click Form1.vb, and then click View Code to open the code view.</li>  In the definition of TabControl1, add the following code. Me.TabControl1.Alignment = TabAlignment.Right </li>  In the definition of TabPage1, use the following code to add text. Me.TabPage1.Text = &quot;Any Text&quot; </li>  To reproduce the behavior, you must call the EnableVisualStyles method in the Main function. Use code that is similar to the following before the &quot;Public Sub New&quot; code block. Public Shared Sub Main

System.Windows.Forms.Application.EnableVisualStyles System.Windows.Forms.Application.Run(New Form1) End Sub </li> On the Project menu, click myTabControl Properties, click Sub Main in the Startup object list, and then click OK.</li> On the Debug menu, click Start.</li></ol>

<div class="references_section">