以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  额,老师,这个要怎么表达。  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=111580)

--  作者:rxfmrqq
--  发布时间:2017/12/25 14:43:00
--  额,老师,这个要怎么表达。

For Each sdr As WinForm.Button In e.Form
Next

厉遍窗口内所有button


--  作者:有点甜
--  发布时间:2017/12/25 14:49:00
--  
For Each c As WinForm.Control In e.Form.controls
    If typeof c Is winform.button Then
       
    End If
Next

--  作者:rxfmrqq
--  发布时间:2017/12/29 13:59:00
--  

For Each c As WinForm.Control In e.Form.controls
    If typeof c Is winform.button Then
        e.from.RemoveControl(c)
    End If
Next

老师, 这个不理解。


--  作者:blackzhu
--  发布时间:2017/12/29 13:59:00
--  
判断类型
--  作者:有点甜
--  发布时间:2017/12/29 14:11:00
--  
以下是引用rxfmrqq在2017/12/29 13:59:00的发言:

For Each c As WinForm.Control In e.Form.controls
    If typeof c Is winform.button Then
        e.from.RemoveControl(c)
    End If
Next

老师, 这个不理解。

 

是一种语法,判断 c 变量是不是某种类型。

 

或者你可以这样写 msgbox(c.gettype.name)


--  作者:rxfmrqq
--  发布时间:2017/12/29 14:34:00
--  

哦, 理解了, 先判断 c 是不是 botton  然后,读出c 的 名称。

但是还是应用不了。 我所有的 button 都是用AddControl 建立的,  c.Gettype.name 出来的名称 全是 button。

 

e.form.RemoveControl("" & c.Gettype.name & "") 出来一点反应都没有。


--  作者:有点甜
--  发布时间:2017/12/29 15:04:00
--  

Dim ns As New List(Of String)

For Each c As WinForm.Control In e.Form.controls
    If typeof c Is winform.button Then
        ns.Add(c.name)
    End If
Next

For Each n As String in ns

    e.from.RemoveControl(n)

Next