动态添加已完成,但不知怎样给它添加事件啊?
各位大哥大姐们帮帮忙吧!
方法一:
Option Explicit
Private WithEvents objCheckBox As CheckBox
Private Sub Form_Load()
Set objCheckBox = Me.Controls.Add("VB.CheckBox", "objCheckBox", Form1)
With objCheckBox
.Caption = "这是动态生成的CheckBox"
.Move 100, 100, 5000, 500
.Visible = True
End With
End Sub
Private Sub objcheckbox_Click()
If objCheckBox.Value = vbChecked Then
MsgBox "Checked", , App.Title
Else
MsgBox "unChecked", , App.Title
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set objCheckBox = Nothing
End Sub
[此贴子已经被作者于2006-12-24 21:26:26编辑过]