[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Closing a Form from another Form

Posted on 2008-11-12
Medium Priority
Last Modified: 2012-05-05
I have an application with 2 panels.
Left panel contains navigation and the right panel contains a toolstrip on which MDI tabs are placed.

I want to allow the user to open as many windows as they want with the only limitation being they can only open ONE of each.

So when Btn1 is pressed for example i check a boolean to see if its open or not. If it is it tells its already open and cant be opened twice, if not it opens. thats easy.

My problem is disposing of each form and clearing the resources. I have added a sub to each form called KillForm() which disposes of everything on each form. But how can i call this sub from the mainForm? this is my code so far attached below.

This wont work because diary doesnt exist as a form when im writing my code. Is there anyway around this?
Private Sub TabStrip1_TabRemoved(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabStrip1.TabRemoved
        If TabStrip1.SelectedTab.Text = "My Diary " Then
            'dispose of all objects and close form
            'set diary open to false
            diaryOpen = False
        End If
    End Sub

Open in new window

Question by:drews1f
LVL 15

Accepted Solution

David L. Hansen earned 2000 total points
ID: 22942148
I'd place your KillForm() routine in a module and have the routine accept a form as a parameter.

Author Comment

ID: 22942171
ahh im new and never thought of that! but that should work!!

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question