PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Tabpage Dynamically adding controls

Reply

Tabpage Dynamically adding controls

 
Thread Tools Rate Thread
Old 12-05-2004, 07:04 PM   #1
Eric
Guest
 
Posts: n/a
Default Tabpage Dynamically adding controls


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???


  Reply With Quote
Old 12-05-2004, 07:30 PM   #2
Eric
Guest
 
Posts: n/a
Default Re: Tabpage Dynamically adding controls

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.

"Eric" <msdnsupport@nospammediserve.com> wrote in message
news:uhEeVuEOEHA.1388@TK2MSFTNGP09.phx.gbl...
> 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???
>
>



  Reply With Quote
Old 13-05-2004, 07:55 AM   #3
Ying-Shen Yu[MSFT]
Guest
 
Posts: n/a
Default RE: Tabpage Dynamically adding controls

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.

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off