动态标签不会显示在指定的 GroupBox 中
Dynamic label won't show in a specified GroupBox
基本上我正在为一个组框创建动态标签,但它只显示我创建的前 10 个,接下来的 10 个不会显示。我很难弄明白。
这是我在组框上添加标签的方法:
Private Sub Create_Numbered_Labels()
Dim x As Integer
''10 First labels
For x = 0 To 9
''Create labels (1 to 10)
Dim lbl As Label = Custom_Label((x + 1).ToString(), "lblNumber" & (x + 1).ToString(), New Point(6, 48 + (x * 38)))
''Add in Groupbox
grpEssais.Controls.Add(lbl)
Next
''10 next labels
For x = 10 To 19
''Create Labels (11 to 20)
Dim lbl As Label = Custom_Label((x + 1).ToString(), "lblNumber" & (x + 1).ToString(), New Point(493, 48 + (x * 38)))
''Add in GroupBox
grpEssais.Controls.Add(lbl)
Next
End Sub
这是我的函数 Custom_Label()
Function Custom_Label(Sent_Text As String, Sent_Name As String, Sent_Location As Point) As Label
''Instance
Dim lbl As New Label()
''DO NOT MODIFY
lbl.AutoSize = False
lbl.Size = New Size(33, 29)
lbl.TextAlign = ContentAlignment.MiddleCenter
lbl.BackColor = Color.White
''MODIFY WITH PARAMETERS
lbl.Text = Sent_Text
lbl.Name = Sent_Name ''LabelName (Sent_Name)-->String
lbl.Location = Sent_Location ''Location (Sent_Location)-->Point() type
''Return the label
Return lbl
End Function
抱歉打扰了。我发现这是我的逻辑错误,
当我创建标签时,我没有将它们放在正确的位置,导致它们超出了组框区域。
Private Sub Create_Numbered_Labels()
Dim x As Integer
''10 First labels
For x = 0 To 9
''Create labels (1 to 10)
Dim lbl As Label = Custom_Label((x + 1).ToString(), "lblNumber" & (x + 1).ToString(), New Point(6, 48 + (x * 38)))
''Add in Groupbox
grpEssais.Controls.Add(lbl)
Next
''10 next labels
For x = 0 To 9
''Create Labels (11 to 20)
Dim lbl As Label = Custom_Label(((x + 1) + 10).ToString(), "lblNumber" & ((x + 1) + 10).ToString(), New Point(493, 48 + (x * 38)))
''Add in GroupBox
grpEssais.Controls.Add(lbl)
Next
End Sub
基本上我正在为一个组框创建动态标签,但它只显示我创建的前 10 个,接下来的 10 个不会显示。我很难弄明白。
这是我在组框上添加标签的方法:
Private Sub Create_Numbered_Labels()
Dim x As Integer
''10 First labels
For x = 0 To 9
''Create labels (1 to 10)
Dim lbl As Label = Custom_Label((x + 1).ToString(), "lblNumber" & (x + 1).ToString(), New Point(6, 48 + (x * 38)))
''Add in Groupbox
grpEssais.Controls.Add(lbl)
Next
''10 next labels
For x = 10 To 19
''Create Labels (11 to 20)
Dim lbl As Label = Custom_Label((x + 1).ToString(), "lblNumber" & (x + 1).ToString(), New Point(493, 48 + (x * 38)))
''Add in GroupBox
grpEssais.Controls.Add(lbl)
Next
End Sub
这是我的函数 Custom_Label()
Function Custom_Label(Sent_Text As String, Sent_Name As String, Sent_Location As Point) As Label
''Instance
Dim lbl As New Label()
''DO NOT MODIFY
lbl.AutoSize = False
lbl.Size = New Size(33, 29)
lbl.TextAlign = ContentAlignment.MiddleCenter
lbl.BackColor = Color.White
''MODIFY WITH PARAMETERS
lbl.Text = Sent_Text
lbl.Name = Sent_Name ''LabelName (Sent_Name)-->String
lbl.Location = Sent_Location ''Location (Sent_Location)-->Point() type
''Return the label
Return lbl
End Function
抱歉打扰了。我发现这是我的逻辑错误, 当我创建标签时,我没有将它们放在正确的位置,导致它们超出了组框区域。
Private Sub Create_Numbered_Labels()
Dim x As Integer
''10 First labels
For x = 0 To 9
''Create labels (1 to 10)
Dim lbl As Label = Custom_Label((x + 1).ToString(), "lblNumber" & (x + 1).ToString(), New Point(6, 48 + (x * 38)))
''Add in Groupbox
grpEssais.Controls.Add(lbl)
Next
''10 next labels
For x = 0 To 9
''Create Labels (11 to 20)
Dim lbl As Label = Custom_Label(((x + 1) + 10).ToString(), "lblNumber" & ((x + 1) + 10).ToString(), New Point(493, 48 + (x * 38)))
''Add in GroupBox
grpEssais.Controls.Add(lbl)
Next
End Sub