private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditorTabPage etb = GetActiveTab();

            if (etb != null)
            {
                if (!etb.Saved)
                {
                    DialogResult dr = MessageBox.Show("You are about to close an unsaved document, do you want to save it now?",
                                                      "MyPad - Save document", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                    if (dr == DialogResult.Yes)
                    {
                        saveToolStripMenuItem_Click(null, null);
                        etb.Dispose();
                    }
                    else if (dr == DialogResult.No)
                    {
                        etb.Dispose();
                    }
                }
                else
                {
                    etb.Dispose();
                }
                SetupActiveTab();
            }
        }
        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb == null)
            {
                return;
            }
            if (tb is SearchTabPage)
            {
                tabControl1.TabPages.Remove(tb);
                tb.Dispose();
                SetupActiveTab();
            }
            if (tb is EditorTabPage)
            {
                EditorTabPage etb = tb as EditorTabPage;

                if (etb.IsSavingNecessary == true)
                {
                    DialogResult dr = MessageBox.Show("You are about to close an unsaved document, do you want to save it now?",
                                                      "MyPad - Save document", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                    if (dr == DialogResult.Yes)
                    {
                        saveToolStripMenuItem_Click(null, null);
                        etb.Dispose();
                    }
                    else if (dr == DialogResult.No)
                    {
                        etb.Dispose();
                    }
                }
                else
                {
                    etb.Dispose();
                }
                SetupActiveTab();
            }
        }