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

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.
MORE INFORMATION

Steps to reproduce the behavior

  1. 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.
  2. Add two new UserControl projects to the solution. Name the UserControl projects UserControl1 and UserControl2.
  3. In the UserControl1 project, open the UserControl1 control. Add a Label object to the control. Name the Label object label1.
  4. Add the following code to the Load event of the UserControl1 control.
    Me.label1.Text = this.DesignMode;
  5. Save and then build the project.
  6. Open the UserControl2 control, and then add the UserControl1 control to the UserControl2 control.
  7. Save and then build the project.
  8. 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.
The label of the nested UserControl1 control reads False, and the label of the non-nested UserControl1 control reads True.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Properties

Article ID: 839202 - Last Review: 11/27/2007 03:42:49 - Revision: 4.6

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

  • kbvs2005swept kbvs2005applies kbprb KB839202
Feedback