# Re: VB6 动态新增控制项做法

Posted by Ringo on July 11, 1999 at 15:15:33:

In Reply to: VB6 动态新增控制项做法 posted by Sephiroth on July 08, 1999 at 15:28:48:

: 没办法, 只好举个例子让大家看看: (VB6 适用)

: Option Explicit

: Private WithEvents Command1 As CommandButton

: Private Sub Command1_Click()
:
: MsgBox "Click Me!"
:
: End Sub

: Private Sub Form_Click()
:
: Set Command1 = Controls.Add("VB.CommandButton", "Command1")
: With Command1
: .Caption = "Run-Time Create"
: .Move (ScaleWidth - .Width) \ 2, (ScaleHeight - .Height) \ 2
: .Visible = True
: End With
:
: End Sub

谢谢
我试了一下,可以正常运作!!

Follow Ups: