I figured out the above issue quite soon after posting, but I'm running into another problem.
I changed my method to take a created label which I wasn't too excited about but it got the job done. Here's the method:
Code:
Public Function buildBasicLabel(ByVal labelName As Label, ByVal text As String, ByVal font As Font, ByVal align As Integer)
Dim tmpLabel
If IsNothing(labelName) Then
tmpLabel = New Label()
Else
tmpLabel = labelName
End If
If IsNothing(font) Then
tmpLabel.Font = New Font(FontFamily.GenericSansSerif, 6.5)
Else
tmpLabel.Font = font
End If
If align = 0 Then
tmpLabel.TextAlign = ContentAlignment.MiddleCenter
Else
tmpLabel.TextAlign = align
End If
tmpLabel.AutoSize = False
tmpLabel.Margin = New Padding(0)
tmpLabel.Text = text
tmpLabel.Anchor = AnchorStyles.None
Return tmpLabel
End Function
Here's sample code of how I use the method:
Code:
Dim spanLabel As New Label()
layout.Controls.Add(cb.buildBasicLabel(spanLabel , "TESTEST", largeLabel, ContentAlignment.MiddleLeft), 2, 2)
layout.setColumnSpan(spanLabel , 3)
layout.Controls.Add(cb.buildBasicLabel(Nothing, "Misc." + vbCrLf + "Test", Nothing, Nothing), 12, 1)