Monday, February 20, 2012

Menustrip disapears in Visual Basic

Fiddling with the resources in a project with a menustrip seems to cause the designer to re-write the XXX.Designer.vb file and drop some key lines from Menustrips ( I have also found references to toolstrip and status strips doing the same thing Here  and  Here and Here .

The problem is that the designer drops the lines that add the menustrip to the form and the sub-items to the menu strip.  I have hand corrected this... but it seems to recur.  (I'm using VS2010 at the moment but the above comments go back to VS2005... so it could be some shared code between the versions)

So on friday the missing line was

Me.TheMenuStrip.Items.AddRange({Me.FileToolStripMenuItem,....blah blah more top level items here})

Now I have lost the above line as well as all the lines on the drop down menus.  So the whole hierarchy has to be rebuilt by hand.

For example

 Me.FileToolStripMenuItem.DropDownItems.AddRange({Me.NewToolStripMenuItem, Me.LoadToolStripMenuItem, ... blah blah more drop down items})

My guess is that the designer will trash all my work at some point in the near future... so I need to find a fix.  Either completely re-create all this and hope it sticks,  turn the designer off or hand code the whole menu structure in a file outside the designers control ... other???

Yet another Pain Point that I don't need.

No comments:

Post a Comment