Okay, for some reason this won't work, but I've done it before.
I'm creating a hangman application, and my dynamic labels simply won't show up.
I wrote this code:
Dim xLabel As Integer = lblPosition.Location.X
Dim yLabel As Integer = lblPosition.Location.Y
For i As Integer = 0 To film.Length - 1
Dim label1 As New Label
xLabel += 20
label1.Location = New Point(xLabel, yLabel)
label1.Text = "_"
label1.Font = New Drawing.Font("Century Gothic", _
16, _
FontStyle.Bold)
label1.ForeColor() = Color.White
label1.Name = "lblLetter" & i
Me.Controls.Add(label1)
Next
So a label is created for every character in the film string, with an underscore as the text. lblPosition is the label on which I base the other label's position.
The labels don't show up. I can change the underscore to something long, and it will just show the last character.
My form is certainly wide enough and I have no label called label1 yet. It compiles as well.
Aucun commentaire:
Enregistrer un commentaire