We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Changing the parent property of control at design time

Hi I am trying to change the parent property of the control that was dragged and dropped in a control container. While doing this i get the error message "The operation is not valid due to current state of the object". I dont know why this error arises. Please look at the code below for MyControl designer: public class SingleViewControlDesigner : ControlDesigner { private Control myControl; public override void Initialize(IComponent component) { base.Initialize (component); myControl = (Control) component; Control target = myControl.Parent.Parent; myControl.Parent = target; target.Controls.Add(myControl); } } Please help me to solve this problem. Thanks in advance, Arun M

Loader.
Live Chat Icon For mobile
Up arrow icon