C # code tutorial for executing another button with one button,
For example, the first button protected void button#click (object sender, EventArgs e ){//?????????? } Second button protected void Button2_Click (object sender, EventArgs e) {button#click (sender, e );}
The second one can use the code of the first button
======================================================== ========================================================== =
You can use delegation to implement this !!
Code!
This. button3.Click + = new System. EventHandler (button2_Click );
Let me explain it to you ~ The previous this. button3.Click is the click event that calls button2!
See it ~ This code is written in the click event of button3!
(Button2_Click) is the method of the click event to be called!
========================================== ======================================
In fact, you are talking about the two buttons to execute the same method. You can define a method. In fact, you double-click the button in it, not an event definition method private void Fun (object sender, EventArg e) {// do something ;} the parameters in this method must be those two and then add two statements to the constructor of this program. This constructor refers to the function button1.Click + = new EventHandler (Fun) in your program set ); button2.Click + = new EventHandler (Fun );