insert control to parent at reverse order.

  • Thread starter Thread starter Mr. X.
  • Start date Start date
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 :)
 
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.
 
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.
 
I found a solution - thanks.
After setting the parent :
Parent.Controls.SetChildIndex(myNewObject, 0)

Thanks :)
 
Back
Top