I'm adding controls to a panel, using the .Controls.Add() function. How does Windows determine the display priority of the newly added controls? That is, if I position a new control so that it overlaps an existing control, which one shows up "on top", the older control or the newly added control?

I'm guessing that it uses the order of the controls as they reside in the Controls array, with the lower indexed ones having lower display priority than the higher indexed ones.

Is that correct?

It's determined by the order they are in in the controls collection. So the first on is on top, the next one under that, etc. So if you add a new control using the Add method it will end up behind all the other controls.

You can use this.Controls.SetChildIndex to change the ordering.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.