ChangeParent() приватный Метод

private ChangeParent ( Control new_parent ) : void
new_parent Control
Результат void
Пример #1
0
			internal virtual void RemoveImplicit (Control control)
			{
				if (impl_list != null)
				{
					all_controls = null;
					impl_list.Remove (control);
					owner.PerformLayout (control, "Parent");
					owner.OnControlRemoved (new ControlEventArgs (control));
				}
				control.ChangeParent (null);
				//owner.UpdateChildrenZOrder ();
			}
Пример #2
0
			public virtual void Remove (Control value)
			{
				if (value == null)
					return;
				
				all_controls = null;
				list.Remove (value);
				
				owner.PerformLayout (value, "Parent");
				owner.OnControlRemoved (new ControlEventArgs (value));
				
				//ContainerControl container = owner.InternalGetContainerControl ();
				//if (container != null) { 
				// Inform any container controls about the loss of a child control
				// so that they can update their active control
				//	container.ChildControlRemoved (value);
				//}
				
				value.ChangeParent (null);
				
				//owner.UpdateChildrenZOrder();
			}
Пример #3
0
			public virtual void Add (Control value)
			{
				if (value == null)
					return;
				
				Form form_value = value as Form;
				Form form_owner = owner as Form;
				//TODO:
				bool owner_permits_toplevels = true;
				// (owner is MdiClient) || (form_owner != null && form_owner.IsMdiContainer);
				bool child_is_toplevel = value.GetTopLevel ();
				bool child_is_mdichild = false;
				//form_value != null && form_value.IsMdiChild;
				if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
					throw new ArgumentException ("Cannot add a top level control to a control.", "value");
				/*
				if (child_is_mdichild && form_value.MdiParent != null && form_value.MdiParent != owner && form_value.MdiParent != owner.Parent) {
					throw new ArgumentException ("Form cannot be added to the Controls collection that has a valid MDI parent.", "value");
				}
				*/				
				
				//value.recalculate_distances = true;
				
				if (Contains (value))
				{
					owner.PerformLayout ();
					return;
				}
				
				if (value.parent != null)
				{
					value.parent.Controls.Remove (value);
				}
				
				all_controls = null;
				list.Add (value);
				
				value.ChangeParent (owner);
				
				//value.InitLayout();
				
				//if (owner.Visible)
				//	owner.UpdateChildrenZOrder();
				owner.PerformLayout (value, "Parent");
				owner.OnControlAdded (new ControlEventArgs (value));
			}
Пример #4
0
			internal virtual void AddImplicit (Control control)
			{
				if (impl_list == null)
					impl_list = new ArrayList ();
				
				if (AllContains (control))
				{
					owner.PerformLayout ();
					return;
				}
				
				if (control.parent != null)
				{
					control.parent.Controls.Remove (control);
				}
				
				all_controls = null;
				impl_list.Add (control);
				
				control.ChangeParent (owner);
				//control.InitLayout ();
				//if (owner.Visible)
				//	owner.UpdateChildrenZOrder ();
				
				// If we are adding a new control that isn't
				// visible, don't trigger a layout
				if (control.VisibleInternal)
					owner.PerformLayout (control, "Parent");
			}
Пример #5
0
			public virtual void Add (Control value)
			{
				if (value == null)
					return;

				Form form_value = value as Form;
				Form form_owner = owner as Form;
				bool owner_permits_toplevels = (owner is MdiClient) || (form_owner != null && form_owner.IsMdiContainer);
				bool child_is_toplevel = value.GetTopLevel();
				bool child_is_mdichild = form_value != null && form_value.IsMdiChild;

				if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
					throw new ArgumentException("Cannot add a top level control to a control.", "value");
				
				if (child_is_mdichild && form_value.MdiParent != null && form_value.MdiParent != owner && form_value.MdiParent != owner.Parent) {
					throw new ArgumentException ("Form cannot be added to the Controls collection that has a valid MDI parent.", "value");
				}
				
				value.recalculate_distances = true;
				
				if (Contains (value)) {
					owner.PerformLayout();
					return;
				}

				if (value.tab_index == -1) {
					int	end;
					int	index;
					int	use;

					use = 0;
					end = owner.child_controls.Count;
					for (int i = 0; i < end; i++) {
						index = owner.child_controls[i].tab_index;
						if (index >= use) {
							use = index + 1;
						}
					}
					value.tab_index = use;
				}

				if (value.parent != null) {
					value.parent.Controls.Remove(value);
				}

				all_controls = null;
				list.Add (value);

				value.ChangeParent(owner);

				value.InitLayout();

				if (owner.Visible)
					owner.UpdateChildrenZOrder();
				owner.PerformLayout(value, "Parent");
				owner.OnControlAdded(new ControlEventArgs(value));
			}