I'm writing a Windows Forms application in VS 2015.
I have part of the form that I want to change, based on a radio selection. The part that I want to change I put in a Panel control.
My current plan was to create 4 control layouts on another form. I created Form2 and created 4 panels on it. I want to copy what's in those panels from Form2 to the Panel in Form1 when the radio button is clicked.
Currently, when I click each radio button, the controls in the Form2 Panel disappear! They are maybe getting moved, not copied. The first one I click does appear on Form 1, but the others do not after that first one. I don't want Form2 (RefPanels) to be changed at all. I just want to copy what's there to Form1. Here's the code I'm trying.
//RefPanels is my Form2 instance.
public Form2 RefPanels = new Form2();
//Each Radiobutton has something similar to this.
RadioBtn1_CheckChanged(...)
{
Control[] cArray = new Control[20];
RefPanels.Panel1.Controls.CopyTo(cArray, 0);
foreach (Control c in cArray)
{
Form1_Destination_Panel.Controls.Add(c);
}
}
I'm sure I'm going about this all wrong. Can you help?