views:

109

answers:

1

My lab partner and I are working on a school project in Visual Studio 2008 in C#. He emailed me the latest version of the project. When I open it, some, but not all, forms that I previously created are now missing all the components that were added to them. However, when I run the project, the components are there and work. Everything on the form except for the border is "hidden."

Any ideas how I can access the missing components and edit the forms? ShowAllForms is active.

It appears something similar to the code below has been added to the .cs code for each form (but not by me). I read elsewhere on the internet that this code could be auto generated by Visual Studios. Could this be the problem? If so, why is Visual Studios adding it to my code?

private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // VideoPoker
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.ClientSize = new System.Drawing.Size(804, 549);
            this.Name = "VideoPoker";
            this.Load += new System.EventHandler(this.VideoPoker_Load_1);
            this.ResumeLayout(false);

        }

Thank you.

A: 

Yes the InitializeComponent() method is automatically added by Visual Studio.

As th name implies, every property of the form itself is initialized and the same goes for any object that you put into the form within the Designer. Everthing that you edit within the designer finally goes into this code section - automatically.

You should never edit this code manually.

Regarding the missing controls, I suppose that for some reason the code was deleted that puts them into the form's ControlCollection which is accessd via the property Form.Controls.

You should check, if the code in the InitializeComponent() method still contains lines like

this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);

for each control which is supposed to be on the form.

Those lines should be far down, near the method's end.

Sensei76
I wouldn't say NEVER modify the code manual, just make sure you know what you're doing if you do.
phsr