您的位置:首页 > 其它

动态添加控件

2005-05-27 08:31 246 查看
Option Explicit
'通过使用 WithEvents 关键字声明一个对象变量为新的命令按钮
Private WithEvents Newbox As CommandButton

'增加控件
Private Sub Command1_Click()
If Newbox Is Nothing Then
'增加新的按钮boxnew
Set Newbox = Controls.Add("VB.CommandButton", "boxnew", Me)
'确定新增按钮boxnew的位置

Newbox.Move Text1.Left + Text1.Width + 240 + Text1.Top
Newbox.Caption = "新增的按钮"
Newbox.Visible = True
End If
End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: