Tabpage Dynamically adding controls

E

Eric

I am completely frustrated trying to control the order that dynamically
created controls appear in a TabPage.

I have tried
tp.Controls.Add(myControl) in a loop which does not work.

I then added my controls to a Control array
Control[] oConts and tried tp.Controls.AddRange(oConts); which does not work

Then I tried, in addition to the above, looping through and explicitly
seting the childindex

with

tp.Controls.SetChildIndex(myCont,iIndex); which still does not work

Is this a known bug or am I overlooking something very simple???
 
E

Eric

After some more investigation I determined the controls were rendering in
the reverse order in which I wanted them. So as a workaround I am able to
achieve what I'm after by adding my controls in reverse order. This makes
no sense but it seems to work.
 
Y

Ying-Shen Yu[MSFT]

Hi Eric,

The order of ControlsCollection is the Z-order of the controls in that
container control. Controls[0] is in the forground and Controls[1] is
behind the Controls[0], etc. If you need add some controls dynamically
from back to front, they should be added to controls collection in reverse
order. I'm not sure why SetChildIndex not work, could you post a small
snippet to show how you use the SetChildIndex method?

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community 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, please remove the word "online"
before sending mail.
 

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