我想要发生的是,当用户点击按钮时,所有标签页中的所有文本框都会被清除。
我使用了这段代码:
For Each page As TabPage In TB_Emp.TabPages
For Each ctl As Control In page.Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
If TypeOf ctl Is ComboBox Then
ctl.Text = ""
End If
If ctl.HasChildren Then
For Each thing As Control In ctl.Controls
If TypeOf thing Is TextBox Then
thing.Text = ""
End If
Next
End If
Next
Next
但它只在第一个标签页上工作,我想在所有标签控制页面上应用此代码
答案 0 :(得分:-1)
尝试循环遍历.TabPages集合中的控件:
Dim tp as TabPage
For Each tp in Tabs.TabPages
For Each ctrl In tp.Controls
'Check for textbox etc.
Next
Next
希望有所帮助
您也可以使用此LINK
试试这个
foreach (Control c in tabPage1.Controls)
{
if (c.GetType() == typeof(TextBox))
{
c.Text = string.Empty;
}
}