more specifically, are these statements
ownerControl.GroupBox1.Controls.Remove(childControl);
ownerControl.Controls.Add(childControl);
an equivalent to
childControl.Parent = ownerControl;
more specifically, are these statements
ownerControl.GroupBox1.Controls.Remove(childControl);
ownerControl.Controls.Add(childControl);
an equivalent to
childControl.Parent = ownerControl;
Looking in reflector, it looks like Parent
just calls Add
(when the new parent is non-null). The Controls.Add
deals with taking it away from the old parent. So actually, the following are functionally equivalent (when ownerControl
is not null):
ownerControl.Controls.Add(childControl); // note no Remove etc
and:
childControl.Parent = ownerControl;
Counter-intuitive, but a quick test shows that it works.