How to make so that in the event of a terminating condition ALL buttons in the form have reacted the same way?

Working with WinForms. Requires that , if in textbox1 is entered a symbol, pressing any button displays a message in the messagebox. can this be done, without prescribing in EACH button_Click'e if ' with a condition to check the text in textbox1?
July 9th 19 at 13:37
2 answers
July 9th 19 at 13:39
Solution
when the form is loaded enough all the controls to bind the event to press a key, the handler well enough to register once, example below. If the user has entered W the notes that have been pressed W and when clicking on any button on the form displays "why did you write Well, quickly erased!" until the user will not erase it from the text field.

public partial class Form1 : Form
{
 public Form1()
{
InitializeComponent();
 foreach (Control item in this.Controls )
{
 item.MouseClick += Item_MouseClick;
}
}

 private void Item_MouseClick(object sender, MouseEventArgs e)
{
 if (keypressed)
{
 if (textBox1.Text.Contains("W"))
{
 MessageBox.Show("why you wrote Well, quickly wiped!");
}
else
{
 MessageBox.Show("Here! and another thing!");
 keypressed = false;
}

}
}

 bool keypressed = false;
 private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
 if (e.KeyChar == 'W')
{
 keypressed = true;
}
}
 }
Thank you for such a detailed response
:) - helene35 commented on July 9th 19 at 13:42
July 9th 19 at 13:41
As a variant - to catch the changed event of the textBox. To clarify what is actually entered by the user. And if he introduced the symbol you want is to consistently bind all the buttons you need an event handler(in this case, if necessary, untie the old processors)

Find more questions by tags C#Windows Forms