Dispose/destroy all objects when returning to the LogOn form
I’m in critical need of some ideas how to destroy/dispose all objects that are created when I’ve been working in my program and logging off, and back to the LogOn form.
To make it all clear:
I’ve 6 classes: RunProgram, FrmLogOn, FrmStudent, FrmCourse, FrmRegister, DBconnect.
Main is in RunProgram and "Application.Run" starts the FrmLogOn. After I’ve been logging in from FrmLogOn the FrmLogOn is set to “this.Hide;” and objStudent is instantiated and set to “objStudent.Show();”. Then it’s the same procedure when going to FrmCourses and FrmRegister, and back to FrmStudent.
In every form there’s a Log Off in the menu. Now I wonder how I destroy all the objects that have been created when I’m returning back to FrmLogOn?
All solutions are welcome! Even those that will change everything I’ve done so far. I just want to find a good way to make it work properly.
Regards,
Nick