Position Control when Created dynamically

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

I have a menu item that creates a new command button.
Each time I create a new command button I need to position it to the left of
the last created button.
In VB6 I could create a control array, look at the UBound of the array (Last
control Created) and find the
position of the last created control in order to place any new controls next
to it.
Creating controls in DotNet is different. I can create the controls
dynamically but have no
way of getting the co-ordinates of the previously created control since
there is no index property.

-Lou
 
Lou,

Of course is there an index property.
The first in an array is 0.

So the previous control is when it is not zero this index -1

Cor
 
Cor, you're talking about the TabIndex, right?

no .

dim mycontrolarray() as control = {Button1, TextBox2, TextBox4, Button2}

The indexes are in that case 0, 1,2,3

Cor
 
There is no index property of a button
I thought you could not have an array of controls in DotNet.
 
There is no index property of a button
I thought you could not have an array of controls in DotNet.

He's talking about the index of an array that contains the control,
not the old VB6 index property.

Thanks,

Seth Rowe
 
Yeah, that's what I suspected, but it wasn't clear. The OP is thinking
about control arrays as they existed in VB6.

Robin S.
 
You can put them in an array yourself in the code behind the form, as Cor
has done in his example.

Robin S.
 
Back
Top