This item is for the Google archive and requires no response.
The VS 2005 Windows Forms Designer has an annoying bug that causes all menu
and toolbar items to disappear if an entry is deleted from the project RESX
document. It may happen at other times, as well, but this is when I've run
into it.
My first reaction was "Holy #$%*! I've got to recreate my menus and
toolbars! There's an afternoon down the tubes!" But it turns out things
aren't quite that bad. The menu and toolbar items weren't trashed by the
designer--only the code in the designer that adds the items to their
containers (menus to the menu bar, and toolbar items to toolbars).
To restore the items, go into the designer code for the form affected. Look
for the section that sets properties for the menu or tool bar you need to
restore. You would normally a statement at the top of the section that looks
something like this:
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.menuFile,
this.menuEdit,
this.menuFormat,
this.menuTools,
this.menuHelp});
That's what was trashed by the Designer. You will need to recreate the
statement by hand. Do that for the main menu (only the menu strip--the
individual menus are okay) and for each toolbar in the application. You
won't need to add tool strip separators back to the main menu (since the
menus themselves weren't trashed), but you will need to add them back to the
toolstrips. Start from the highest-number toolStripSeparator you find in the
designer and work your way backward--that will avoid adding any of the menu
separators a second time.
It took about fifteen minutes to restore my form. It sure beats the heck out
of spending the afternoon recreating menus and toolbars!
David Veeneman
Foresight Systems
RobinS - 31 Dec 2006 00:43 GMT
Were the items still on the form itself, and they were only
mucked up in the designer file? Or were they missing from the
form? Did you try just re-generating the designer file?
Robin S.
--------------------------------------
> This item is for the Google archive and requires no response.
>
[quoted text clipped - 41 lines]
> David Veeneman
> Foresight Systems