只是对前两个非常好的答案的重新哈希。在这里,它试图说明至少必须根据用户提供的逻辑设置位置和文本
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' YOU decide where EACH new label goes and pass the X,Y for each
' new label; YOU decide on the text and pass it. you can make them
' variables, but YOU have to do some of the thinking....
' <...> == information YOU provide
Private x As integer = <where you want the new label>
Private y as integer = <where you want the new label>
Private txt as String = <Text for this new label>
' EXAMPLEs
' a) set text from a textbox
' txt = txtLblText.Text
' b) Set X position from another code integer variable
' x = thisX
' c) Set Y position from textbox input
' y = Integer.Parse(txtLblYPos.Text)
Dim lbl as Label = MakeNewLabel(x, y, txt As string)
Me.Controls.Add(lbl)
End Sub
Friend function MakeNewLabel(x as integer, y as Integer, txt As String) as label
Dim lbl As New label
' add other label props here as needed
lbl.Size = New System.Drawing.Size(159, 23) 'set your size
lbl.Location = New System.Drawing.Point(x, y) 'set your location
lbl.Text = txt
Return lbl
End Function