Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to create labels programmatically, nothing shows

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
in the Page load. Nothing shows on the screen that I can see anyway. form color is white. What am I missing?
here is code
Code:
         Dim MyLabel As Label
        Dim a, x, y As Integer
        x = 100
        x = 10
        For a = 1 To 50
            MyLabel = New Label
            MyLabel.Name = "TractorLabel" & Trim(a.ToString)
            MyLabel.Height = 98
            MyLabel.Width = 10
            MyLabel.AutoSize = False

            MyLabel.BackColor = Color.DarkMagenta
            MyLabel.Left = x + y
            MyLabel.Top = 250
            MyLabel.BorderStyle = BorderStyle.FixedSingle
            MyLabel.Visible = True
            y = y + 10
            Debug.Print(MyLabel.Name)
        Next
TractorLabel1, TractorLabel2, etc shows in the immediate window if it step throught the code
What am I missing?
TIA

DougP
[r2d2] < I Built one
 
I got it. need to add the label to the controls of the form like so
Me.Controls.Add(MyLabel)
Code:
            y = y + 10
            Debug.Print(MyLabel.Name)
            Me.Controls.Add(MyLabel) <<<<<
        Next

DougP
[r2d2] < I Built one
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top