Link to home
Start Free TrialLog in
Avatar of DustinHinkel
DustinHinkel

asked on

Need to fire event on form close

in vb.net 2005 .  I have two forms open,  form1 and form2, is there a way to fire an event on form1 when form2 closes?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Yes...in Form1, subscribe to Form2's closing event...

Does Form1 create Form2?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DustinHinkel
DustinHinkel

ASKER

Form2 is opened from a command click from Form1, but not created from form1 if I understand you right.  Fairly new to this.  How do i "subscrive to Form2's closing event?
See above...  ;)
Thanks that worked.  But when I put the code in my project i get an error going in design view.  It says:


 One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.

The type Form1 is made of several partial classes in the same file.
Hide    

at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)


Not sure what you did...

Make sure you have only ONE declaration for each form:

    Public Class Form1
        ...
    End Class
    Public Class Form1
        ...
    End Class

So in the above example, move everything from the second "Form1" class up into the first, and get rid of the second "Form1" class declaration.  Other than that, I'm not sure...
Sorry, I'm an idiot.  Learning would be impossible without people like  you.  Thanks