I do not want to press a button. instead, I just want to run the click event code. how would i do that?
button1_click(null, new EventArgs() );
Option: use PerformClick().
PerformClick()
Take a look here: How to invoke the "Click on event" button Programmatically .
The advantage here is that the behavior of the event will be exactly the same as the actual click of a button (like a direct call button1_click).
button1_click
. , ! button1_click .
Inside or outside Form, where is it located Button? The easiest way is to simply call the function:
Form
Button
Button1_Click(Button1, EventArgs.Empty);
Try keybd_event with p / invoke http://msdn2.microsoft.com/en-us/library/ms646304(VS.85).aspx
I sometimes do this by actually calling the event handler function what if I really implemented it.Literally call it this:
button1_Click(this, new EventArgs());