How to add the same control in multi panel to C #?


I have a button called button1 and two panels called: panelA and panelB (visible is false by default) and the following code (WinForms):

panelB.Visible = true; // I see the button1
panelA.Visible = true; // I don't (ofcoz panelB.Visible is still false)
MessageBox.Show(panelA.Controls.Contains(button1).ToString); //False, why?

I don't know why? Maybe it's a stupid question for you but I'm a newbie so I don't really have any idea about this problem? Can you help me? Thanks!

The object button1 can have only one visual parent. Therefore you shouldn't add it to 2 different parents.

So, you need to have 2 button objects.