Question Label forecolor not updating on dynamic controls

R22MPM

New member
Joined
Apr 18, 2012
Messages
4
Programming Experience
Beginner
Hi all,
I am dynamically creating some labels on a form at runtime using this code

VB.NET:
            Dim digit = New Label
            digit.Width = 40
            digit.Visible = True
            'set the font size
            digit.Font = New System.Drawing.Font("Calibri", 12.0, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            digit.Name = "FirstDigit_" & QN
            If LineNumber > 15 Then
                digit.Location = New Point(hpos, pos)
            Else
                digit.Location = New Point(hpos, pos)
            End If
            'pos = pos + 30
            digit.Enabled = False
            digit.Text = number
            digit.BackColor = Color.Transparent
            digit.ForeColor = Color.Red
            digit.BringToFront()
            Me.Controls.Add(digit)

But when testing the form the colour of the text never changes. Anyone seen this before?
 

Latest posts

Back
Top