Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Form lost objects in design window
 

Form lost objects in design window

I am working on a windows application in Visual C# 2005 Express Edition. So far every thing has worked OK, but today when I open the project the cs [Design] window only shows an empty form with no controls on it. All the system generated code in xxx.Designer.cs and other files is there, and build (F6) reports no errors. But running the application just shows an empty form like the design window.

Any explanation for this and any tricks to get around it?

Harald Mejlholm  Wednesday, March 08, 2006 9:21 AM
I have not found out, why all controls on my form disappeared even though they were defined in the Form1.Designer.cs file. The problem is, that all the stmts, that links the controls to the form (this.Controls.Add(...)) has disappeared. It may be because, I have manually changed the Form1.Designer.cs file, which there is a warning about at the top of the file. After i added such stmts, the controls were of course visible again on the frame. Some other stmts had also disappeared - f.ex. EventHandler stmts.
Harald Mejlholm  Saturday, March 11, 2006 10:12 AM
This is something that is indeed very frustrating; I've experienced it in VS.NET 2003 as well.

Are you making use of form inheritance ? I know that, if you use form inheritance, the chances are bigger that this error occurs.
What I always do now, is, before I build my solution, close every design window I might have have open.

Frederik Gheysels  Wednesday, March 08, 2006 10:18 AM

Thank you for your interest. No I'm not using form inheritance, and closing the design window has no effect. I have even tried reinstalling Visual Studio C# - with no helping effect either. So I think the problem - and therefore also the solution - lies in the project files. It seems like the development environment ignores all the system generated code, that creates the controls on the form. I have tried setting a breakpoint at the start of Form1.Designer.cs - just to make sure, that this code is processed - which it is.

So I'm still wondering what to do...

Harald Mejlholm  Thursday, March 09, 2006 10:03 AM
I have not found out, why all controls on my form disappeared even though they were defined in the Form1.Designer.cs file. The problem is, that all the stmts, that links the controls to the form (this.Controls.Add(...)) has disappeared. It may be because, I have manually changed the Form1.Designer.cs file, which there is a warning about at the top of the file. After i added such stmts, the controls were of course visible again on the frame. Some other stmts had also disappeared - f.ex. EventHandler stmts.
Harald Mejlholm  Saturday, March 11, 2006 10:12 AM

You can use google to search for other answers

Custom Search

More Threads

• Setting a textbox control's focus on Form load
• Question about a Design time component!
• adding designtime support for property of usercontrol (InitializeComponents)
• PrintDialog From/To Page
• Please help with Phone Book Application
• ultradockmanager
• Custom Toolstrip Collection Items options are not save.
• Error in Updating database table using OdbcDataAdapter.Update() method
• Get All TimeZone And Language
• Expanding control