Click to See Complete Forum and Search --> : BringToFront changes Control order


gbr
July 10th, 2005, 06:40 PM
Hi,

I am using numerous panels (let's call them A-panels) which are added on a host panel. To access them I use host.Controls[index]. On the host panel, there are some other panels which should in the foreground. They must be visible, so I call their BringToFront method. Unfortunately this function disorders the A-panels which makes it impossible to index them.

Is there a way to bring the panels to the front without changing the order in host.Controls?

gbr

wildfrog
July 10th, 2005, 07:02 PM
Is there a way to bring the panels to the front without changing the order in host.Controls?
Probably not, why not have a separate list for your "a-panels", and use that list for "indexing"?

- petter

gbr
July 10th, 2005, 07:07 PM
I wanted to have stored their references only once (in host.Controls). If I won't find any solution I must use a separate list...

gbr

wildfrog
July 10th, 2005, 07:17 PM
Well, if you read MSDNs remaks section of Control.ControlCollection.SetChildIndex(...)

When SetChildIndex is called, the Control referred to by the child parameter is moved to the position specified by newIndex and the other Control references in the Control.ControlCollection are reordered to accommodate the move. The control with an index value of zero is at the top of the z-order, and higher numbers are closer to the bottom.
.. you'll see that the collection index is related to the z-order.

- petter