Click here to Skip to main content
15,906,569 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir,
My problem is that when i call event handler method in a simple method .Please help,thanks..
Posted
Updated 30-Nov-12 4:01am
v2
Comments
thursunamy 30-Nov-12 9:52am    
Can you send piece of code ?
Neel_Sharma 30-Nov-12 9:57am    
THis is Eventhandler :

public void Keyload(object sender, EventArgs e)
{
actHook = new UserActivityHook();
actHook.KeyDown += new KeyEventHandler(MyKeyDown);
actHook.KeyPress += new KeyPressEventHandler(MyKeyPress);
actHook.KeyUp += new KeyEventHandler(MyKeyUp);
}

But How to call in Function(Only Function)
ZurdoDev 30-Nov-12 10:30am    
And the problem is?

1 solution

Don't.

Instead, create a method that the Event handler calls and call that instead.
You don't need to call an event handler directly, although you can - it's just not good practice.

If you must, then just call it - it is a method so you just need to provide the parameters.
C#
MyKeyUp(myKey, new EventArgs());
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900