I have a tabControl that contains many textBoxes, I want to add a button to clear all textBoxes's texts at once, I tried this code:
private void ClearButton_Click(object sender, EventArgs e)
{
foreach (TextBox t in tabControl1.SelectedTab.Controls)
{
t.Clear();
}
}
But this code doesn't work, i got this error message :
Unable to cast object of type 'System.Windows.Forms.Button' to type 'System.Windows.Forms.TextBox
What is wrong in this code?