Click here to Skip to main content
12,511,494 members (50,622 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
Dear sir,
My problem is that when i call event handler method in a simple method .Please help,thanks..
Posted 30-Nov-12 3:47am
Updated 30-Nov-12 4:01am
v2
Comments
thursunamy 30-Nov-12 9:52am
   
Can you send piece of code ?
NeelmaniN 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)
ryanb31 30-Nov-12 10:30am
   
And the problem is?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
MyKeyUp(myKey, new EventArgs());
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 30 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100