Creating Label Array

  • Thread starter Thread starter Adrian
  • Start date Start date
A

Adrian

Hi
In VB6 if you copied and then past a control it asked you if you want to
create an array dotnet doesn't!

I want to create an array of Labels at design time not runtime can this be
done in VB dotnet?

If so how?

thanks
 
July 24, 2005

Actually I have heard that when pasting controls, it AUTOMATICALLY creates
a collection. I'm not sure how you access the collection, but supposedly it
creates one itself.....

--
Joseph Bittman
Microsoft Certified Application Developer

Web Site: http://71.39.42.23
Static IP
 
OK What I'm trying to do is put a load of data in to a matrix 16 lines/rows
by 10 columns. I just want to be able to run a simple for next loop that
will be used to control what row it goes to and within the loop it will post
the data to cell 1 -10 (or 0 - 9).

I have tried using the datagrid and the listview, but can not get them to
work in this manner so I was just going to create an array, is there a
better way ?

the rows and columns need to be aligned and I would like to alternate each
rows background colour

thanks
 
Adrian,

Does this little sample gives you an idea for your question (you can use of
course as well labels)?

\\\Needs only a new form and pasting this beneath in
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To 5
Dim bt As New Button
bt.Location = New Drawing.Point(8, 8 + i * 24)
bt.TabIndex = i
bt.Text = i.ToString
bt.Tag = i.ToString
AddHandler bt.Click, AddressOf ClickButton
Controls.Add(bt)
Next
End Sub
Private Sub ClickButton(ByVal sender As Object, _
ByVal e As EventArgs)
MessageBox.Show("Clicked was " & _
DirectCast(sender, Button).Tag.ToString)
End Sub
///
I hope this helps a little bit?

Cor
 
Just one other thing on this, if I now want to redirect the out put i.e I
want to create the controls not on form1 but on a tab control on form1 how
do I do that?

thanks
 
Adrian,

the only thing that change than is
tabpage1.Controls.add(bt)

I hope this helps,

Cor
 
Back
Top