以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 已解决!动态控件的删除问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=51011) |
-- 作者:bahamute -- 发布时间:2014/5/17 0:29:00 -- 已解决!动态控件的删除问题 以下代码生成一组标签控件: Dim bks() As String Dim i As Integer bks = New String() {"A","B","C","D"} For Each bk As String In bks Dim lbl As WinForm.Label i = i+1 lbl = e.Form.CreateControl("lable" &
i+1, ControlTypeEnum.Label) lbl.Text = bk lbl.Left = 700 lbl.Top = 350 + i*20 e.Form.AddControl(lbl) Next 现在想批量删除这组控件,却发现删除代码不起作用: Dim bks() As String bks = New String()
{"A","B","C","D","E"} For Each bk As String In bks If e.Form.ExistControl(bk)=True Then messagebox.Show(bk) e.Form.RemoveControl(bk) End If
Next 求指点! [此贴子已经被作者于2014-5-17 22:33:33编辑过]
|
-- 作者:lsy -- 发布时间:2014/5/17 8:09:00 -- Dim bks() As String Dim i As Integer bks = New String() {"A","B","C","D"} For Each bk As String In bks Dim lbl As WinForm.Label i = i+1 lbl = e.Form.CreateControl(bk, ControlTypeEnum.Label) lbl.Text = bk lbl.Left = 70 lbl.Top = 35 + i * 20 e.Form.AddControl(lbl) Next |
-- 作者:bahamute -- 发布时间:2014/5/17 22:09:00 -- 谢谢回复,但不是想问的问题,我想知道生成这组控件后,如何通过代码删除它,代码在一楼。 |
-- 作者:bahamute -- 发布时间:2014/5/17 22:34:00 -- Dim bks() As String Dim i As Integer bks = New String() {"A","B","C","D"} For Each bk As String In bks Dim lbl As WinForm.Label i = i+1 lbl = e.Form.CreateControl(bk, ControlTypeEnum.Label) lbl.Text = bk lbl.Left = 700 lbl.Top = 350 + i*20 e.Form.AddControl(lbl) Next |