Not sure how to select a textbox from multiple textboxes on a form and clear it on the click event of a button. For example, if we have multiple operand fields for a calculator and need to implement clear current field button, how do I implement it? Here is the code snippet I have so far.
private void button2_Click(object sender, EventArgs e)
{
foreach (Control t in this.Controls)
{
if (t is TextBox)
{
if (t.Focused)
{
t.Text = "";
}
}
}
}