我有一个可以创建4000个新按钮的程序但是我花了30秒才完成它。反正有没有让它更快?
For x = 1 To 4000
Dim btnNew As New Button()
btnNew.Width = 14
btnNew.Height = 11
btnNew.Location = New Point(a, b)
Me.Controls.Add(btnNew)
btn(k) = btnNew
Next
答案 0 :(得分:4)
您确实需要做三件事:
所以试试:
Me.SuspendLayout()
Try
For x As Integer = 1 To 4000
Dim btnNew As New Button()
btnNew.Width = 14
btnNew.Height = 11
btnNew.Location = New Point(a, b)
Me.Controls.Add(btnNew)
btn(k) = btnNew
Next
Catch ex As Exception
Throw
Finally
Me.ResumeLayout()
End Try