Position Control when Created dynamically

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
 
C

Cor Ligthert [MVP]

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
 
C

Cor Ligthert [MVP]

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
 
L

Lou

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

rowe_newsgroups

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
 
R

RobinS

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.
 
R

RobinS

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

Robin S.
 

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