CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Location
    .NET 4.0/VS2010
    Posts
    79

    [RESOLVED] close original form

    hi everyone,

    so i have a question. i have an application that uses multiple forms. but on the second form(form2) i have in the menu, an option to quit the application. how can i set the action to that menu item to close the second form, and the first form(form1)?

    thanks

    rockking

  2. #2
    Join Date
    Jan 2010
    Posts
    1,133

    Re: close original form

    If the second form has a direct reference to the form1, than you should be able to call the Close() method on it. If not, you can use events, and make the original form respond by closing itself, but you would have to modify your code just a little bit. If the application started with something like Application.Run(form1), then the process should end when the form closes.

  3. #3
    Join Date
    Dec 2008
    Posts
    144

    Re: close original form

    This is a little brute force, but Application.Quit() should kill everything.

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: close original form

    Expose an event from your child form that the main form can handle. When this event fires the main form can close itself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured