System.Windows.Forms.MdiClient.ChildFormClosed C# (CSharp) Method

ChildFormClosed() private method

private ChildFormClosed ( Form form ) : void
form Form
return void
		internal void ChildFormClosed (Form form)
		{
			FormWindowState closed_form_windowstate = form.WindowState;
	
			form.Visible = false;
			Controls.Remove (form);
			
			if (Controls.Count == 0) {
				((MdiWindowManager) form.window_manager).RaiseDeactivate ();
			} else if (closed_form_windowstate == FormWindowState.Maximized) {
				Form current = (Form) Controls [0];
				current.WindowState = FormWindowState.Maximized;
				ActivateChild(current);
			}

			if (Controls.Count == 0) {
				XplatUI.RequestNCRecalc (Parent.Handle);
				ParentForm.PerformLayout ();

				// If we closed the last child, unmerge the menus.
				// If it's not the last child, the menu will be unmerged
				// when another child takes focus.
				MenuStrip parent_menu = form.MdiParent.MainMenuStrip;

				if (parent_menu != null)
					if (parent_menu.IsCurrentlyMerged)
						ToolStripManager.RevertMerge (parent_menu);
			}
			SizeScrollBars ();
			SetParentText (false);
			form.Dispose();
		}

Usage Example

Example #1
0
        private void FormClosed(object sender, EventArgs e)
        {
            mdi_container.ChildFormClosed(form);

            if (form.MdiParent.MainMenuStrip != null)
            {
                form.MdiParent.MainMenuStrip.RefreshMdiItems();
            }

            mdi_container.RemoveControlMenuItems(this);
        }