动态添加控件
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
'通过使用 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
相关文章推荐
- 给动态控件添加事件
- iOS通过代码动态添加和删除控件
- Android--动态添加控件
- MFC动态创建控件及添加消息响应
- ASP.NET动态添加TextBox控件
- 动态添加服务器控件
- WPF:理解ContentControl——动态添加控件和查找控件
- C# DataGridView控件 动态添加新行
- 关于页面动态添加控件
- 动态添加控件
- Master模板的ASPX页面动态添加控件
- vb.net2005动态添加网页控件的事件
- JS动态添加删除控件
- VB6动态添加控件
- MFC中动态添加控件----寻找多年的秘籍,吐血推荐
- Android GridLayout 动态添加子控件 + 平均分配空间
- DateTime比较 动态添加控件事件
- 怎么给Table动态添加控件并且得到控件的值?
- JavaScript动态添加和删除控件
- 控件的动态添加与消息响应