Thanks KONI for that infinitely productive and enlightening response.
Brane, you want a button from one form moved to another?
like an example, my ok button from my main form moved to the settings form? or like you have a button inside a panel and you want to move it to the main form instead of being inside that panel?
so if i have a button named button1 and a panel named panel1
i could assign to button1's click method this function and it will alter the parent.
private void button1_Click(object sender, EventArgs e)
if (button1.Parent == this)
button1.Parent = panel1;
button1.Parent = this;
Since the parent changes, the "Location" that is assigned to the button is applied towards its parent so if you have your button at 12,12 and your panel at 30,30 you will see a difference when you click the button.
is this what your looking for? or you want to move the button to a totally different form all together?
if you want to move it to a new form, you have to have that form created and shown first
so if i have a button that creates my form and shows it
then i have another button that when clicked you can alter the parent like this.
private void button3_Click(object sender, EventArgs e)
f = new Form2();
this is all code in my form1 and my class has a member variable called f that is declared like
private void button2_Click(object sender, EventArgs e)
button2.Parent = f;