Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Notify Parent Form of close

Notify Parent Form of close

Scheduled Pinned Locked Moved Visual Basic
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    K Shaffer
    wrote on last edited by
    #1

    How can I make a modeless form notify its parent that it has closed? Thanks -mE

    J 1 Reply Last reply
    0
    • K K Shaffer

      How can I make a modeless form notify its parent that it has closed? Thanks -mE

      J Offline
      J Offline
      Joshua Quick
      wrote on last edited by
      #2

      Your parent form should catch the modeless form's Closed event. Parent Form Code:

      Public Class ParentForm : Inherits System.Windows.Forms.Form
      '
      ' Keep a member variable of modeless form. Use WithEvents.
      Private WithEvents myModelessForm As New ModelessForm
      '
      ' Show the modeless form.
      Private Sub ParentForm_Load(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) _
      Handles MyBase.Load
      myModelessForm.Show()
      End Sub
      '
      ' Catch the modeless form's Closed event.
      Private Sub myModelessForm_Closed(ByVal sender As Object, _
      ByVal e As System.EventArgs) _
      Handles myModelessForm.Closed
      MessageBox.Show("Modeless form was closed!")
      End Sub
      End Class

      K 1 Reply Last reply
      0
      • J Joshua Quick

        Your parent form should catch the modeless form's Closed event. Parent Form Code:

        Public Class ParentForm : Inherits System.Windows.Forms.Form
        '
        ' Keep a member variable of modeless form. Use WithEvents.
        Private WithEvents myModelessForm As New ModelessForm
        '
        ' Show the modeless form.
        Private Sub ParentForm_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) _
        Handles MyBase.Load
        myModelessForm.Show()
        End Sub
        '
        ' Catch the modeless form's Closed event.
        Private Sub myModelessForm_Closed(ByVal sender As Object, _
        ByVal e As System.EventArgs) _
        Handles myModelessForm.Closed
        MessageBox.Show("Modeless form was closed!")
        End Sub
        End Class

        K Offline
        K Offline
        K Shaffer
        wrote on last edited by
        #3

        This worked nicely. Many Thanks -mE

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups