以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [原创]遍历窗口指定TabControl里面的按钮控件(已解决)?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=130768)

--  作者:lunengcheng
--  发布时间:2019/1/31 15:04:00
--  [原创]遍历窗口指定TabControl里面的按钮控件(已解决)?
各位老师前辈好,我的窗口里面有三个TabControl,现在想遍历第三个,也就是TabControl里面的按钮控件,但是我写的代码老报错,希望老师能帮忙看一下!

For Each c As WinForm.button In e.Form.Controls("TabControl3")   
messagebox.Show(c.name)
Next
[此贴子已经被作者于2019/1/31 18:07:21编辑过]

--  作者:有点甜
--  发布时间:2019/1/31 15:11:00
--  
For Each p As WinForm.TabPage In e.Form.Controls("TabControl1").tabpages
    For Each c As object In p.Children
        If Typeof c Is winform.button Then
            msgbox(c.name)
        End If
    Next
Next

--  作者:lunengcheng
--  发布时间:2019/1/31 15:41:00
--  
老师,好像调用不出来,是不是跟按钮是放在页面中的面板有关呢?
--  作者:有点甜
--  发布时间:2019/1/31 15:53:00
--  
For Each p As WinForm.TabPage In e.Form.Controls("TabControl1").tabpages
    For Each c As object In p.Children
        If Typeof c Is winform.panel Then
            For Each cc As object In c.children
                If Typeof cc Is winform.button Then
                    msgbox(cc.name)
                End If
            Next
        End If
    Next
Next

--  作者:lunengcheng
--  发布时间:2019/1/31 18:07:00
--  
代码可以用了,多谢老师!