以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助] 想要引用 TabControl 页面子控件集合 Children 中的控件,这段代码怎么执行不了呢?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=154468)

--  作者:龙潭春早
--  发布时间:2020/9/15 17:50:00
--  [求助] 想要引用 TabControl 页面子控件集合 Children 中的控件,这段代码怎么执行不了呢?
想要引用 TabControl 页面子控件集合 Children 中的控件,这段代码怎么执行不了呢?

代码:

Dim tbp As WinForm.TabPage
Dim ctr As WinForm.Control
Dim btn As WinForm.Button

tbp = Forms("窗口1").Controls("TabControl").TabPages(2)

output.show("")

If tbp.Children.Count > 0 Then
    output.show("")
    For Each ctr In tbp.Children
        If Typeof ctr Is WinForm.Button Then
            btn = ctr
            output.show(btn.Name)
        End If
    Next
End If


--  作者:有点蓝
--  发布时间:2020/9/15 20:16:00
--  
output.show(tbp.Children.Count) \'有几个控件?

If tbp.Children.Count > 0 Then
    For Each ctr In tbp.Children
    output.show(ctr.name) ‘分别显示什么名称?
        If Typeof ctr Is WinForm.Button Then
            btn = ctr
            output.show(btn.Name)
        End If
    Next
End If

注意Children只是返回第一层控件,比如tabpage里有一个panel,panel有其它控件。Children只能返回panel,无法返回panel里面的控件的

--  作者:龙潭春早
--  发布时间:2020/9/15 22:59:00
--  

帮助中介绍容器的Children属性时,大都提到其“返回一个集合,包括所有顶层子控件。


这些“顶层子控件”,指的也都是第一层的控件吗?


--  作者:有点蓝
--  发布时间:2020/9/15 23:19:00
--  

--  作者:龙潭春早
--  发布时间:2020/9/16 0:21:00
--  
谢谢