如何样遍历Panel1下面的子控件
怎么样遍历Panel1下面的子控件?我这么写VB.NET codeFor Each Content As Content In Panel1.ControlsConte
怎么样遍历Panel1下面的子控件?
我这么写
VB.NET code For Each Content As Content In Panel1.Controls Content.GetType() Next
错误为
无法将类型为“System.Web.UI.LiteralControl”的对象强制转换为类型“System.Web.UI.WebControls.Content”。
何解?
[解决办法]你总要判断一下 Content 是不是你要的类型吧,否则出错就很正常了
[解决办法]foreach (Control cl in Panel1.Controls)
{
}
[解决办法]C# code For Each cc As Control In Panel1.Controls cc.GetType() Next
[解决办法]
For Each ctl as Control In Panel1.Controls
If ctl.GetType().ToString() = "System.Web.UI.WebControls.Content" Then
End If
Next