以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  遍历控件的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=147141)

--  作者:akkio99
--  发布时间:2020/3/10 17:58:00
--  遍历控件的问题

With Tables("数据表")

 
If .Current IsNot Nothing And .Current.locked=True Then
 .Current.Locked = False

 For Each c As WinForm.Control In e.Form.Controls("Panel1")
    If Typeof c Is WinForm.TextBox Then \'判断控件是否是文本框
       Dim t As WinForm.TextBox = c \'使用特定类型的变量引用控件
               t.BackColor = color.white

    ElseIf  Typeof c Is WinForm.Datetimepicker Then \'判断控件是否是文本框
        Dim da As winform.Datetimepicker=c
        da.BackColor = color.white

End If
Next

End If

End With

 

大神,请问为什么不能遍历某个控件中的控件呢? 有什么解决办法吗?

[此贴子已经被作者于2020/3/10 17:58:26编辑过]

--  作者:akkio99
--  发布时间:2020/3/10 18:01:00
--  
.NET Framework 版本:4.0.30319.36543
Foxtable 版本:2019.10.26.1
错误所在事件:窗口,收费录入,Button8,Click
详细错误信息:
无法将类型为“Foxtable.WinForm.Panel”的对象强制转换为类型“System.Collections.IEnumerable”。

--  作者:有点蓝
--  发布时间:2020/3/10 20:20:00
--  
For Each c As WinForm.Control In e.Form.Controls("Panel1").Children