Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Main form has lost menus
 

Main form has lost menus

I was working on some resources (icons, bitmaps, etc) that were associated with my main form. Suddenly all of my menu items are not "attached" to my main menu.
I have a MenuStrip called mainMenuStrip on the form, and the instance is still there. In addition I still see references to fileToolStripMenuItem, but it is no longer associated as an item in the mainMenuStrip.
Any ideas as to what happened and or how I can reassociate the items? If I try to add fileToolStripMenuItem, it tells me that I can't name it that because it already exists.

I'd hate to have to get from source control as it's been two days since I checked in.
bpeikes  Wednesday, June 24, 2009 4:06 PM
Hi bpeikes,

You can go the .Designer.cs file and add the items to the MenuStrip in the following way in the InitializeComponent() method:

private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.aaaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.bbbbToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.bbbToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.bbbbToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.aaaToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.bbbbToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.aaaToolStripMenuItem1,
this.bbbbToolStripMenuItem2});

this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(489, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
.....
}


Best Regards,
Zhi-Xin


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Zhi-Xin Ye  Thursday, June 25, 2009 2:07 PM
That's exactly what I did. I wanted to know what could have caused the problem so I can avoid losing work again.
bpeikes  Thursday, June 25, 2009 2:24 PM

Which version of Visual Studio do you use?

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Zhi-Xin Ye  Friday, June 26, 2009 9:08 AM

You can use google to search for other answers

Custom Search

More Threads

• inheriting from an existing Windows Forms control
• Collection Editor
• resizing a user control on the designer
• Changing the TypeEditor of a property
• show fomr in a Tab page
• Implementing SnapLines at RunTime
• Diagonal Labels
• Custom Control inherited from GroupBox
• UPLOADING A PICTURE
• Setting DesignerLoader.LoaderHost.RootComponent to an existing Control