Displaying Labels Created at Runtime

I want to create an array of label controls at runtime in a Windows app ... nine rows by nine columns. My problem is that when I do this the labels are not displayed in the application window. Is there some property I have to set to cause this to happen? Here is the sub I go to to do this: (this routine is executed when I click a Go button)

PrivateSub btnGo_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles btnGo.Click

Dim iAsInteger
Dim jAsInteger
Dim cells(8, 8)As Label
For i = 0To 8
For j = 0To 8
cells(i, j) =
New Label
cells(i, j).Width = 40
cells(i, j).Height = 40
cells(i, j).Text =
CStr(i * 9 + j + 1)
cells(i, j).Top = 70 + i * 10
cells(i, j).Left = 70 + j * 20
cells(i, j).ForeColor = Color.Blue
cells(i, j).BorderStyle = BorderStyle.FixedSingle
cells(i, j).Visible =
True
cells(i, j).TextAlign = ContentAlignment.MiddleCenter
cells(i, j).AutoSize =
False
Next
Next
EndSub

[2561 byte] By [fripper] at [2007-12-16]
# 1
Oops ... I forgot to mnetion that I using VS 2005 Beta 2 ...
fripper at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 2
you simply need to add the controls to the window.
try adding this into your loop
Me.Controls.Add(cells(i, j))
exhibit at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 3
Arrggghhh ... why didn't I know that?!? Thanks very much.
fripper at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified