各位大大,小弟小白刚学代码,想把textbox数量根据自己需求动态增加和减少,代码如下:
Public Class Form1
Private N As Integer
Private PL As Integer 'textbox相对于窗体的duLeft
Private PT As Integer 'textbox相对于窗体的Top
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
TextBox1.Text = N
For i = 1 To N
Dim newtextbox As New TextBox
newtextbox.Left = PL
newtextbox.Top = PT
Me.Controls.Add(newtextbox)
PT += newtextbox.Height + 10 '各 newtextbox上下间隔10-------PL不变是希望左对齐
Next
End Sub
End Class
可是调试之后,在textbox里面写数字,却不见新得文本框出现呢??
并不是height+10好吧,是上一个控件的TOP+上一个height,高度没算明白。。。