Example #1
0
        // [Empty Recycle Bin] Menu Item
        private void emptyRecycleBinToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (formEmptyRecycleBin == null)
            {
                formEmptyRecycleBin           = new EmptyRecycleBin();
                formEmptyRecycleBin.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.

                formEmptyRecycleBin.FormClosed += formEmptyRecycleBin_FormClosed;
                formEmptyRecycleBin.Show();
            }

            else
            {
                // if the Form is already open
                formEmptyRecycleBin.Activate();
            }
        }
Example #2
0
 // [Empty Recycle Bin]
 private void formEmptyRecycleBin_FormClosed(object sender, FormClosedEventArgs e)
 {
     formEmptyRecycleBin = null;
 }