Exemplo n.º 1
0
        /// <summary>
        /// When a different MDI child is activated,
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormMain_MdiChildActivate(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild == null)
            {
                this.tabMain.Visible = false; // If no any child form, hide tabControl
            }
            else
            {
                this.ActiveMdiChild.WindowState = FormWindowState.Maximized; // Child form always maximized

                // If child form is new and no has tabPage, create new tabPage
                if (this.ActiveMdiChild.Tag == null)
                {
                    MyFormPage mfp = this.ActiveMdiChild as MyFormPage;
                    if (mfp != null)
                    {
                        MyTabPage newPage = new MyTabPage(mfp);
                        this.tabMain.TabPages.Add(newPage);

                        this.tabMain.SelectedTab = newPage;

                        this.ActiveMdiChild.Tag         = newPage;
                        this.ActiveMdiChild.FormClosed += new FormClosedEventHandler(ActiveMdiChild_FormClosed);

                        this.tabMain.Show();
                    }
                }
                else
                {
                    MyTabPage mtp = this.ActiveMdiChild.Tag as MyTabPage;
                    this.tabMain.SelectedTab = mtp;
                }
            }
            this.UpdateMenu();
        }
Exemplo n.º 2
0
 public MyTabPage(MyFormPage subFrm)
 {
     this.m_frm = subFrm;
     this.Controls.Add(subFrm.MainPanel);
     this.Text      = subFrm.Text;
     this.BackColor = System.Drawing.SystemColors.Window;
 }