Exemplo n.º 1
0
        // [Add Site] Menu Item
        private void addSiteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (formAddSite == null)
            {
                formAddSite           = new AddSite();
                formAddSite.MdiParent = this;
                // In the current context += means subscribe. In other words it's like you are telling subscribe my method (the right operand)
                // to this event (the left operand), this way, when the event is raised, your method will be called. Also, it is a good practice
                // to unsubscribe (-= from this event, when you have finished your work ( but before you dispose you object ) in order to prevent
                // your method being called and to prevent resource leaks.

                formAddSite.FormClosed += formAddSite_FormClosed;
                formAddSite.Show();
            }

            else
            {
                // if the Form is already open
                formAddSite.Activate();
            }
        }
Exemplo n.º 2
0
 // [Add Site]
 private void formAddSite_FormClosed(object sender, FormClosedEventArgs e)
 {
     formAddSite = null;
 }