I have a form with tab control , and each tab has a number of textboxes , labels and buttons . I want the user to be able to clear all the text in the text boxes of the selected tab.
I tried
private void resetCurrentPageToolStripMenuItem_Click(object sender, EventArgs e) { foreach (TextBox t in tabControl1.SelectedTab.Controls) { t.Text = ""; } }
In the above code, InvalidCastException with the message Unable to cast object of type 'System.Windows.Forms.Button' to type 'System.Windows.Forms.TextBox .
Pls what i did wrong and how can i fix it?
c # winforms textbox
user2509901
source share