您的位置:首页 > 编程语言 > VB

C#、VB遍历控件并赋值

2014-11-19 18:26 429 查看

 C#遍历控件并赋值:

foreach (Control ct in form1.Controls)
{
if (ct is TextBox ) {
(ct as TextBox).Text = "";
}
if (ct is DropDownList) {
(ct as DropDownList).SelectedValue = "";
}
}



VB遍历控件并赋值:

For Each ct As Control In Me.Controls
If TypeOf ct Is TextBox Then
CType(ct, CheckBox).Text = ""
End If
Next


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: