Help!! 如何动态删除控件?

snowerhuayun 2003-09-22 03:52:55
我知道用control.add可以动态加入控件,那么如何将这些动态生成的控件删除呢?(通过程序)
...全文
147 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wx05 2003-09-23
  • 打赏
  • 举报
回复
unload 就可以了吧
Fengq 2003-09-23
  • 打赏
  • 举报
回复
controls.remove
gzqg 2003-09-23
  • 打赏
  • 举报
回复
up
watt 2003-09-22
  • 打赏
  • 举报
回复
Unload 不行吗?
northwolves 2003-09-22
  • 打赏
  • 举报
回复
Private WithEvents NewButton As CommandButton

Private Sub Command1_Click() '增加控件
If NewButton Is Nothing Then

Set NewButton = Controls.Add("VB.CommandButton", "cmdNew", Me) '增加新的按钮cmdNew

NewButton.Move Command1.Left + Command1.Width + 240, Command1.Top '确定新增按钮cmdNew的位置
NewButton.Caption = "新增的按钮"
NewButton.Visible = True
End If
End Sub


Private Sub Command2_Click() '删除控件
If NewButton Is Nothing Then
Else
Controls.Remove NewButton
Set NewButton = Nothing
End If
End Sub

Private Sub NewButton_Click() '新增控件的单击事件
MsgBox "您选中的是动态增加的按钮!"
End Sub
rainstormmaster 2003-09-22
  • 打赏
  • 举报
回复
Dim mytext As TextBox
Private Sub Command1_Click()
Set mytext = Controls.Add("VB.TextBox", "mytext", Me)
mytext.Left = 100
mytext.Top = 100
mytext.Visible = True
End Sub

Private Sub Command2_Click()
Controls.Remove mytext
End Sub

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧