[英]Clear Textbox in Tab Control vb.net
What I want to happen is that when a user clicks on button, all Text-Boxes in all Tab Pages are cleared. 我想发生的是,当用户单击按钮时,所有选项卡页中的所有文本框都被清除。
I used this code : 我使用此代码:
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
But it's only working on the first tab page, I want to apply this code on all Tab Control Pages 但这仅在第一个标签页上起作用,我想将此代码应用于所有标签页控制页
Try looping over the controls in the .TabPages collection instead: 尝试循环遍历.TabPages集合中的控件:
Dim tp as TabPage
For Each tp in Tabs.TabPages
For Each ctrl In tp.Controls
'Check for textbox etc.
Next
Next
Hope it helps 希望能帮助到你
also you can use this LINK 您也可以使用此LINK
Try this 尝试这个
foreach (Control c in tabPage1.Controls)
{
if (c.GetType() == typeof(TextBox))
{
c.Text = string.Empty;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.