Groups | Blog | Home
all groups > vb.net > february 2007 >

vb.net : Position Control when Created dynamically


RobinS
2/7/2007 9:50:34 PM
Cor, you're talking about the TabIndex, right?

Robin S.
------------------------------
[quoted text, click to view]

Lou
2/7/2007 11:19:14 PM
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

Cor Ligthert [MVP]
2/8/2007 6:40:39 AM
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 Ligthert [MVP]
2/8/2007 7:12:30 AM

[quoted text, click to view]

no .

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

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

Cor


Lou
2/8/2007 7:42:37 AM
There is no index property of a button
I thought you could not have an array of controls in DotNet.


[quoted text, click to view]

rowe_newsgroups
2/8/2007 8:29:21 AM
[quoted text, click to view]

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

Thanks,

Seth Rowe
RobinS
2/9/2007 12:02:58 AM
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.
-------------------------------------
[quoted text, click to view]

RobinS
2/9/2007 12:03:36 AM
You can put them in an array yourself in the code behind the form, as Cor
has done in his example.

Robin S.
------------------------------------
[quoted text, click to view]

AddThis Social Bookmark Button