DetailPage-MSS-KB

Microsoft small business knowledge base

Article ID: 839202 - Last Review: November 27, 2007 - Revision: 4.6

On This Page

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.

REFERENCES

For more information about Windows Forms and about user controls, visit the following Microsoft Web sites:


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

http://msdn2.microsoft.com/en-us/library/Aa984070(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/Aa984070(VS.71).aspx)

http://msdn2.microsoft.com/en-us/library/Aa984216(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/Aa984216(VS.71).aspx)

http://msdn2.microsoft.com/en-us/library/Aa984079(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/Aa984079(VS.71).aspx)

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
Keywords: 
kbvs2005swept kbvs2005applies kbprb KB839202
Share
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support