Codes for reattch: Form2 Codes
Form1 frm1 = new Form1();
this.MdiParent = frm1;
this is the problem whenever I reattach the child form nothing happens.
No, it won't.
Because the instance of Form1 that you are "reattaching" to is not the original, and is not even displayed - it is a totally different instance! The keyword
new
here should give you a clue about this. :laugh:
It's like a car: if you put your mobile phone in the glove box of your car, and sell it to buy a new car, would you expect to find your phone in the new cars glove box?
When you "detach" the form2, either save the Parent instance and use that instance for reattaching, or better still create a events within Form2 which ask the Parent to detach and reattach the form. That way, form2 does not need to know about it's parent.