View Single Post
  #2 (permalink)  
Old September 15th, 2007, 12:06 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You forgot to assign a *new* label to the lblDisplay name variable. With the current code, you overwrite the existing label on each iteration. Try this instead:
Code:
For row = 0 To 15
  For column = 0 To 15
    lbldisplay = New Label()
    lbldisplay.Name = row & "," & column
    lbldisplay.Size = New Size(labelsize, labelsize)
    lbldisplay.Top = toplabeltop + (row * labelsize)
    lbldisplay.Left = labelleft + (column * labelsize)
    lbldisplay.BackColor = Color.Black
    frmDisplay.Controls.Add(lbldisplay)
  Next
Next
HtH,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote