View Single Post
  #1 (permalink)  
Old September 15th, 2007, 11:02 AM
peter-h peter-h is offline
Registered User
Join Date: Sep 2007
Location: Manchester, , United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add multiple labels to a form at run time

I'm trying to populate a form with 256 labels arranged as a 16 X 16 block with the labels tight to each other. In the following code 'labelsize', 'toplabeltop' and 'labelleft' are set by code (not shown) that uses 'Screen.PrimaryScreen.Bounds' to establish the screen size and then sets the form size.

The relevant code for populating the form is:

        Dim lbldisplay As New Label
Dim labelsize As Integer, toplabeltop As Integer, labelleft As Integer, row As Integer, column As Integer

        For row = 0 To 15
            For column = 0 To 15
                lbldisplay.Name = row & "," & column
                lbldisplay.Size = New Size(labelsize, labelsize)
                lbldisplay.Top = toplabeltop + (row * labelsize)
                lbldisplay.Left = labelleft + (column * labelsize)
                lbldisplay.BackColor = Color.Black


The problem is that only the last label is visible. What am I missing?

Reply With Quote