Add Controls seems to need to be done in reverse?

W

William Stacey

Adding three text boxes to a panel and Left docking them to each other. It
seems they need to be added to the panel control in reverse order or else
tb3 will appear before tb2, etc. Even if the position is defined with tb1
at 0,0 and so on. Is this behavior documented or some reason for this? TIA
this.panel1.Controls.Add(this.textBox3);
this.panel1.Controls.Add(this.textBox2);
this.panel1.Controls.Add(this.textBox1);
 
Y

Ying-Shen Yu[MSFT]

Hi William,

Thanks for your post!

This is an "By Design" issue.
After much debation, our product team decided to use z-order as the docking
order,
internally the controls are docked from bottom to top in z-order, and the
ControlsCollection is considered to be in z-order (top control first), so
you need add controls in reverse order if you want to dock them.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
P

Pete Davis

The order of adding them affects the tab order of the controls, I believe.
For this same reason, it would also affect the docking if they're docked
together. As far as I know, this isn't documented. I would recommend
downloading Anakrino and looking at the actual System.Windows.Forms code.
There's a lot of undocumented functionality and the only real way to
understand what's going on is to look at the code.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top