I've a custom control which gets updated continuously with external data. I've two panels, one of them contains the custom control.
I want to move the custom control from one panel to another upon a button click and it looks like the control is getting deleted after call to Controls.Remove
Panel1.Controls.Remove(customControl); // looks like this delete that customControl object
Panel2.Controls.Add(customControl); // Throws an exception "Object reference not set to instance of an object"
So my question is how can I reuse my customControl after call to Remove. Please note that:
1) I can't create two instance of customControl because of some side effects.
2) If I create a new instance of customControl after call to Remove, I'll lose the old data which is not desirable.