Microsoft KB Archive/839202

= The DesignMode property of a nested user control is always set to False in Visual Studio .NET or in Visual Studio 2005 =

Article ID: 839202

Article Last Modified on 11/27/2007

-

APPLIES TO


 * Microsoft Common Language Runtime (included with the .NET Framework) 1.0
 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition

-





SYMPTOMS
When you work with Microsoft Windows Forms in Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005, the DesignMode property of a user control may be set to False.



CAUSE
This behavior occurs at design time in Microsoft Visual Studio .NET or in Microsoft Studio 2005 if you nest a user control inside another user control. When you do this, the DesignMode property of the nested user control will return False. If a user control contains another user control, only the root level user control will return True.



Steps to reproduce the behavior
 In Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005, use Microsoft Visual Basic .NET or Microsoft Visual Basic 2005 to create a Windows Application project. By default, a Windows Form that is named Form1 is created. Add two new UserControl projects to the solution. Name the UserControl projects UserControl1 and UserControl2. In the UserControl1 project, open the UserControl1 control. Add a Label object to the control. Name the Label object label1.  Add the following code to the Load event of the UserControl1 control. Me.label1.Text = this.DesignMode;  Save and then build the project. Open the UserControl2 control, and then add the UserControl1 control to the UserControl2 control.</li> Save and then build the project.</li> In the Windows Forms project, open the Form1 form in design view, and then add the UserControl1 control and the UserControl2 control to the Form1 form.</li></ol>

The label of the nested UserControl1 control reads False, and the label of the non-nested UserControl1 control reads True.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="references_section">