Results 1 to 3 of 3

Thread: Closing a window

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    1

    Closing a window

    Okay, I just got started using VB .NET 2003 in a maintenance role and I have to start by fixing the following problem. There is a window in my program that has an exit button. When a user pushes the exit button a procedure is called and "certain things" happen. However, if the user uses the X in the top right corner, or if ALT + F4 is pressed, the procedure is not called which is the problem. How do I tie the exit procedure into the other window closing options?

    Thanks...

  2. #2
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: Closing a window

    The form has 2 closing events, FormClosed and FormClosing. Move the code that is in the exit button's event to one of these. Then just call close from the exit button.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Closing a window

    Just note that FormClosing and FormClosed are new in .NET 2.0. In .NET 1.x you would use the Closing and Closed events. Note also that those events will not be raised if you call Application.Exit to quit the app.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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