Results 1 to 8 of 8

Thread: Events on form unload...?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210

    Events on form unload...?

    I only see (Declarations), Finalize, InitializeComponent, and New.

    How can I allow something to happen on form close?

    Thanks.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210
    It works when I use
    VB Code:
    1. Private Sub form1_closed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Closed
    but isn't there any way that I can just choose it from a list or something? Like in VB6.

    I had to copy the form_load thing and change load to closed.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210
    What about opening another form when you close the main form?

    It was possible using VB6 by just showing a form on form unload. But in VS.Net, when put the code, "f.Show()" and "MsgBox ("what")", the main form was closed, new form opened, but when I closed the msgbox the program closed.

    Any help?

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If you want a list of form events then you can select (base class events) in the left combo and then the right one will list all the available events.

    As for spawning a new form off of the main form, the main thread of your application has to be tied to one form and when that one closes then it will closes all others. You can show a new form modally and that will keep the thread active until the new form is closed.

    f.ShowDialog()


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210
    Originally posted by Edneeis
    As for spawning a new form off of the main form, the main thread of your application has to be tied to one form and when that one closes then it will closes all others. You can show a new form modally and that will keep the thread active until the new form is closed.

    f.ShowDialog()

    I understand the first part but I don't get the second part about keeping the thread active..

    Could you explain in more detail?

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Well the application has a 'main' thread which is based on the the Sub Main, or first Form. When that item ends it terminates the thread or the application. So you you can't have a form you plan on ending as the main form. Showing a form modally stops the execution of code on the thread until modal form is closed.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210
    So.. How would you show a form "modally"?

    Thanks.

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You use the ShowDialog method instead of the Show method.

    f.ShowDialog()

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