Changing parent container

  • Thread starter Thread starter Young
  • Start date Start date
Y

Young

Can someone please help? I am trying to move a panel (standard .NET panels)
control to another panel at run time.

I've 2 panels - Panel1 and Panel2. Both's parent are current the form
container.

When I click on a button, I want to make Panel1 the parent of Panel2. I have
change the background color so I can see what is happening. Also, I make
Panel2 smaller than Panel1 to make sure I can see it in Panel1.

Here are the codes in the button click event:

Panel2.Parent = Panel2
Panel2.BringToFront

When I click on the button, I can see Panel2 is no longer visible and
"possible" moved to Panel1. But I cannot see Panel2 within Panel2.

Can someone please help?

TIA
Young
 
Can someone please help? I am trying to move a panel (standard .NET panels)
control to another panel at run time.

I've 2 panels - Panel1 and Panel2. Both's parent are current the form
container.

When I click on a button, I want to make Panel1 the parent of Panel2. I have
change the background color so I can see what is happening. Also, I make
Panel2 smaller than Panel1 to make sure I can see it in Panel1.

Here are the codes in the button click event:

Panel2.Parent = Panel2
Panel2.BringToFront

When I click on the button, I can see Panel2 is no longer visible and
"possible" moved to Panel1. But I cannot see Panel2 within Panel2.

After you move the (now child) panel, do you set its Location to
ensure that it is correctly positioned in its parent panel?
 
Hi Young, this is how i will do that:

panel2.Parent = panel1;
panel2.Location = new Point( 10, 10 );
panel2.BringToFront();

Hope that helps
Jerónimo Milea
 
Thanks all for replying.

I did not set the location. It works when I set the location.

Young

Can someone please help? I am trying to move a panel (standard .NET
panels)
control to another panel at run time.

I've 2 panels - Panel1 and Panel2. Both's parent are current the form
container.

When I click on a button, I want to make Panel1 the parent of Panel2. I
have
change the background color so I can see what is happening. Also, I make
Panel2 smaller than Panel1 to make sure I can see it in Panel1.

Here are the codes in the button click event:

Panel2.Parent = Panel2
Panel2.BringToFront

When I click on the button, I can see Panel2 is no longer visible and
"possible" moved to Panel1. But I cannot see Panel2 within Panel2.

After you move the (now child) panel, do you set its Location to
ensure that it is correctly positioned in its parent panel?
 
Back
Top