MdiForm Design is gone!

J

jp2msft

What would cause VS2005 Pro to lose all of my MdiForm Design information?

I've been working on one of the Child Forms and having problems with the
Child Form's threads not completing (locking up and not responding anymore).

So, I shut down VS, turned off my PC, then turned everything back on.

Now, my MdiForm Design looks like a blank form whenever a new form is added
to a project. My Tray Icon, Status Bar strip, and Main Menu are all there,
but nothing is on the form.

What would cause Visual Studio to dump this? Is there a way that I can
salvage it? (probably not)
 
M

Morten Wennevik [C# MVP]

jp2msft said:
What would cause VS2005 Pro to lose all of my MdiForm Design information?

I've been working on one of the Child Forms and having problems with the
Child Form's threads not completing (locking up and not responding anymore).

So, I shut down VS, turned off my PC, then turned everything back on.

Now, my MdiForm Design looks like a blank form whenever a new form is added
to a project. My Tray Icon, Status Bar strip, and Main Menu are all there,
but nothing is on the form.

What would cause Visual Studio to dump this? Is there a way that I can
salvage it? (probably not)

Hi,

What MdiForm design do you mean? As far as I know the VS designer wont
display child windows at design time, so how are you able to see them on the
MdiForm. Or do you mean UserControls? These can be dragged onto any form or
control and be displayed in the VS designer. However, an MdiForm also has a
MdiClient control added to it. If the MdiClient is somehow pushed topmost
(like MdiClient.BringToFront()) all other controls will appear to vanish as
they are put underneath.

If you are putting UserControls on your MdiParent and they vanish I'm
guessing the MdiClient is covering them. If so, try checking your code for a
MdiClient reference and make sure you aren't putting it in front of the
usercontrols.
 
J

jp2msft

Morten Wennevik said:
Hi,

What MdiForm design do you mean? As far as I know the VS designer wont
display child windows at design time, so how are you able to see them on the
MdiForm. Or do you mean UserControls? These can be dragged onto any form or
control and be displayed in the VS designer. However, an MdiForm also has a
MdiClient control added to it. If the MdiClient is somehow pushed topmost
(like MdiClient.BringToFront()) all other controls will appear to vanish as
they are put underneath.

If you are putting UserControls on your MdiParent and they vanish I'm
guessing the MdiClient is covering them. If so, try checking your code for a
MdiClient reference and make sure you aren't putting it in front of the
usercontrols.

Mr. Wennevik,

Actually, what has happened is that my MdiForm lost all of its settings. The
Main Menu, Status Bar, and Tray Icon controls still appear in Design Mode,
but the Main Form has lost all of its settings. The name is now "Form1"
(where it was my application's name), it is not set to be an MDI Form, there
is no Menu associated with the form (even though the Main Menu is still
located there), my application's icon is gone, ...everything has been reset!
You name it - it is no longer on my MDI form.
 
M

Morten Wennevik [C# MVP]

jp2msft said:
Mr. Wennevik,

Actually, what has happened is that my MdiForm lost all of its settings. The
Main Menu, Status Bar, and Tray Icon controls still appear in Design Mode,
but the Main Form has lost all of its settings. The name is now "Form1"
(where it was my application's name), it is not set to be an MDI Form, there
is no Menu associated with the form (even though the Main Menu is still
located there), my application's icon is gone, ...everything has been reset!
You name it - it is no longer on my MDI form.

Ah,

It sounds like Visual Studio in the chaos found the need to recreate the
form.designer.cs file and thereby managed to overwrite the original settings.
In that case, your old settings are probably gone unless you have some form
of source control. If you do have source control, replace the entire content
of <mdiform>.designer.cs with the older version. Also make sure you have a
call to InitializeComponent() in the constructor.
 
J

jp2msft

Morten Wennevik said:
Ah,

It sounds like Visual Studio in the chaos found the need to recreate the
form.designer.cs file and thereby managed to overwrite the original settings.
In that case, your old settings are probably gone unless you have some form
of source control. If you do have source control, replace the entire content
of <mdiform>.designer.cs with the older version. Also make sure you have a
call to InitializeComponent() in the constructor.

I've got most of my fields added back onto the form by now. My problem now
is getting my Main Menu back!

Any idea how to do this?

I have specified that the Main Menu is the MdiForm's MainMenuStrip item, but
it does not actually appear on the form.

I don't suppose you would have any idea of how to do this?

I'd really rather not have to recreate my Main Menu, as I go through and
replace all of Visual Studio's very long names with something much simpler
(toolstripmenuitemFileOpen with miOpen), and that takes *hours* to do!
 
J

jp2msft

Ok, I found what I needed:

In the MdiForm's Designer.cs file, I added these items:

this.Controls.Add(this.MainMenu);
this.Controls.Add(this.StatusBar);
this.Controls.Add(this.TrayIcon);

However, the instructions say "do not modify the contents of this method
with the code editor."

Will my changes be lost? How do I ensure that these settings stay?
 
M

Morten Wennevik [C# MVP]

jp2msft said:
Ok, I found what I needed:

In the MdiForm's Designer.cs file, I added these items:

this.Controls.Add(this.MainMenu);
this.Controls.Add(this.StatusBar);
this.Controls.Add(this.TrayIcon);

However, the instructions say "do not modify the contents of this method
with the code editor."

Will my changes be lost? How do I ensure that these settings stay?

:

As long as you make sure you use the correct format when editing the
designer file you should be safe. The section is handled by Visual Studio
but editing it manually should update the designer as well. To add a control
to the designer section manually you need to add tre parts shown below.
After you add them go to the designer view and the control should pop up.
The safest way is to then cut away the control and paste it back. This will
let Visual Studio write the correct lines of code. Simpler things like
moving controls from one container to another, changing properties etc can be
done manually in the designer code just fine. You should, however, leave the
name property untouched in the designer file and change this in the designer
instead.

this.myControl = new MyControl();

....


///
/// myControl
///
this.myControl.Property1 = ...
....


....

private MyControl myControl;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top