U want to add the method textBox1_KeyPress to KeyPress eventhandler of other textboxes as well.
U can do this
1. using the GUI builder in Visual Studio:
Select all the appropriate textboxes in the GUI builder (by holding down the control key). Then in the properties window, click on the small lightning icon. Navigate down to keyPress event and click the down arrow in front of it. There u will find this method named textBox1_KeyPress. Click on it.
OR
2. using code:
write this somewhere in your
Form1_Load(object sender, EventArgs e)
or
Form1()
method:
textBox2.KeyPress+=textBox1_KeyPress;
textBox3.KeyPress+=textBox1_KeyPress;
textBox4.KeyPress+=textBox1_KeyPress;
and so on...
Actually if You use method 1, the code in method 2 automatically gets written in InitializeComponent() method in Form1.Designer.cs file.
*Replace "Form1" by name of the form in question.