Code for Menu File Exit

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi,

A simple question ..

In the design mode I added the standard File Menu, so, New,
Open, Save etc. to my Window Form application.

On File Exit, I added code like:
private void FileExit_clicked(object sender, EventArgs e)
{
this.Close();
}

but nothing happened.

The form does not disappear from the screen.

Seems to be something wrong ??

Thx,
Chris
 
Chris,

What is "this" pointing to? If it is the form, then it *should* close,
and all the child windows as well.

Have you also tried the static Exit method on the Application class in
the System.Windows.Forms namespace?

Hope this helps.
 
It seems my function *FileExit_clicked* is not called at
all, if I click File|Exit..

Do I have to change something in the properties. Now I see
name like *menuitem6* etc. Is that OK ?

I never worked with menus before ..



"Nicholas Paldino [.NET/C# MVP]"
Chris,

What is "this" pointing to? If it is the form, then it *should* close,
and all the child windows as well.

Have you also tried the static Exit method on the Application class in
the System.Windows.Forms namespace?

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Chris said:
Hi,

A simple question ..

In the design mode I added the standard File Menu, so, New,
Open, Save etc. to my Window Form application.

On File Exit, I added code like:
private void FileExit_clicked(object sender, EventArgs e)
{
this.Close();
}

but nothing happened.

The form does not disappear from the screen.

Seems to be something wrong ??

Thx,
Chris
 
Back
Top