本文整理汇总了C#中System.Windows.Forms.Control.ChangeParent方法的典型用法代码示例。如果您正苦于以下问题:C# Control.ChangeParent方法的具体用法?C# Control.ChangeParent怎么用?C# Control.ChangeParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Control
的用法示例。
在下文中一共展示了Control.ChangeParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveImplicit
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: Remove
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: Add
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: AddImplicit
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: Add
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));
}