Disappearing main menu

  • Thread starter Thread starter Joel
  • Start date Start date
J

Joel

I have a Windows Form application that's been running fine for over a year.
I've been making modifications lately and noticed that both my main menu and
my form Icon disappear when I run the application. They show up in the VS
designer and I can modify them but when I run the app they're gone. All the
controls on my form the amount that the menu would've taken up and my icon
reverts to the default windows icon.

My resource file looks ok but I'm no expert on it. Anybody seen this?

TIA

</joel>
 
It happens to couple of times with the MainMenu. The problem in all of the
cases was that the VS serialized failed to serialize setting the form's Menu
property to the MianMenu component. Thus the menu might be visible at design
time, but at run time disappears.

What you can do is go in the form's InitializeComponents and fine the
section where the form is initilized (this is the last section in the
method) .Let say your main menu is called mainMenu. There should be line

this.Menu = this.mainMenu;

If the line is not there add it. The designer will keep the change
 
That's the first thing I checked and the this.Menu=this.mainMenu line is
there. I even tried deleting and recreating the menu -- same behavior.

Stoitcho Goutsev (100) said:
It happens to couple of times with the MainMenu. The problem in all of the
cases was that the VS serialized failed to serialize setting the form's Menu
property to the MianMenu component. Thus the menu might be visible at design
time, but at run time disappears.

What you can do is go in the form's InitializeComponents and fine the
section where the form is initilized (this is the last section in the
method) .Let say your main menu is called mainMenu. There should be line

this.Menu = this.mainMenu;

If the line is not there add it. The designer will keep the change

--

HTH
Stoitcho Goutsev (100) [C# MVP]


Joel said:
I have a Windows Form application that's been running fine for over a year.
I've been making modifications lately and noticed that both my main menu
and
my form Icon disappear when I run the application. They show up in the VS
designer and I can modify them but when I run the app they're gone. All
the
controls on my form the amount that the menu would've taken up and my icon
reverts to the default windows icon.

My resource file looks ok but I'm no expert on it. Anybody seen this?

TIA

</joel>
 
Well I managed to fix my problem but it doesn't make any sense. No matter
what, if the line this.Menu=this.mainMenu1 appears in the default location
(in InitializeComponent) my form appears with no menu and a corrupted icon.

I moved the line from InitializeComponent and put it in my Form_Load and
everything works fine. argh.

</joel>
 
Back
Top