Foxtable(狐表)用户栏目专家坐堂 → [求助]请教怎么遍历窗口表


  共有3663人关注过本帖树形打印复制链接

主题:[求助]请教怎么遍历窗口表

帅哥哟,离线,有人找我吗?
昱飞哥
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:324 积分:2504 威望:0 精华:0 注册:2020/3/2 23:15:00
[求助]请教怎么遍历窗口表  发帖心情 Post By:2022/5/7 13:53:00 [只看该作者]

窗口中,有个页面集合TabControl1,页面集合中含有多个Table,我写了下面的代码遍历这些Table,报错。

For Each c As WinForm.Control In e.Form.Controls("TabControl1").controls
    If Typeof c Is WinForm.Table Then '判断控件是否是Table
        Dim t As WinForm.Table = c '使用特定类型的变量引用控件
        MessageBox.Show(c.Table.name)
    End If
Next

我的疑问有2个:
1、上面的代码怎么修改?
2、如果我除了页面集合TabControl1之外还有其他的容器控件,比方panel1,要是panel1里面也有Table,那这个Table也能一起遍历出来吗?

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/5/7 14:11:00 [只看该作者]

For Each p As WinForm.TabPage In e.Form.Controls("TabControl1").tabpages
    For Each c As WinForm.Control In p.children
        If TypeOf c Is WinForm.Table Then '判断控件是否是Table
            Dim t As WinForm.Table = c '使用特定类型的变量引用控件
            MessageBox.Show(t.name)
        ElseIf TypeOf c Is WinForm.Panel Then
            Dim pnl As WinForm.Panel = c
            For Each c2 As WinForm.Control In pnl.children
                If TypeOf c2 Is WinForm.Table Then '判断控件是否是Table
                    Dim t2 As WinForm.Table = c '使用特定类型的变量引用控件
                    MessageBox.Show(t2.name)
                End If
            Next
        End If
    Next
Next

 回到顶部