insert control to parent at reverse order.

M

Mr. X.

Hello.

I see that, when insert controls to the same parent on the following way :
control1.parent = commonParent
control2.parent = commonParent

commonParent.controls(0) ' this is coltrol1
commonParent.controls(1) ' this is control2

But, when I am doing so on design time, the order is reversed (and that
what's I need).
commonParent.controls(0) ' this is coltrol2
commonParent.controls(1) ' this is control1

How can I insert into the parent, the controls with reverse-order?

Thanks :)
 
C

Cor Ligthert[MVP]

Design time and runtime is not different in VB versions newer then VB6.

Everything which is done in design time is created as code which runs at
runtime.

Take a look at the file, YourProgram.designer.vb

The adding to the control collections is maybe evaluated every time again
at design time, therefore you are told not to change that, because then you
can get unpredictable results.

However, the way controls are added to the control collections, is not
important, like every collection it has no fixed sequence, it is just
filling up down.
 
P

Phill W.

I see that, when insert controls to the same parent on the following way :
control1.parent = commonParent
control2.parent = commonParent

commonParent.controls(0) ' this is coltrol1
commonParent.controls(1) ' this is control2

But, when I am doing so on design time, the order is reversed (and that
what's I need).
commonParent.controls(0) ' this is coltrol2
commonParent.controls(1) ' this is control1

How can I insert into the parent, the controls with reverse-order?

Annoying, isn't it?

Why do you need them in any particular order within the parent's
Controls collection? If you're trying to set the navigational (tab)
order, you can set the TabIndex property separately.

HTH,
Phill W.
 
M

Mr. X.

I found a solution - thanks.
After setting the parent :
Parent.Controls.SetChildIndex(myNewObject, 0)

Thanks :)
 

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