Click here to Skip to main content
15,915,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to take out controls from one panel and store that controls in another panel.

Example:
I have two panel
1.panel1
2.panel2

I added a button into the panel1.After some time i want to add the panel1 controls into panel2.

Please suggest how to solve this problem.

Thanks
Posted

1 solution

Try:
C#
foreach (Control c in Panel1.Controls)
   {
   Panel2.Controls.Add(c); 
   } 
Panel1.Controls.Clear();



"How can i put controls in panel2 from panel1 in reverse manner.
Means:If panel1 contains 2 controls.pos1.Label and pos2.Button

I want to show the button in first position and label in second position.

Please help.

Thanks"



Try:
C#
for (int i = Panel1.Controls.Count - 1; i >= 0; i--)
    {
    Panel2.Controls.Add(panel1.Controls[i]);
    }
 
Share this answer
 
v2
Comments
bhagirathimfs 4-Apr-12 8:29am    
How can i put controls in panel2 from panel1 in reverse manner.
Means:If panel1 contains 2 controls.pos1.Label and pos2.Button

I want to show the button in first position and label in second position.

Please help.

Thanks
OriginalGriff 4-Apr-12 9:38am    
Answer updated
bhagirathimfs 4-Apr-12 9:55am    
Thanks a ton OriginalGriff
OriginalGriff 4-Apr-12 10:02am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900