Click here to Skip to main content
Rate this: bad
good
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
Edited 30-Nov-12 4:01am
v2
Comments
thursunamy at 30-Nov-12 9:52am
   
Can you send piece of code ?
NeelmaniN at 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 at 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
0 OriginalGriff 349
1 Nirav Prabtani 268
2 _Amy 185
3 CHill60 170
4 Richard Deeming 135
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,067
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 30 Nov 2012
Copyright © CodeProject, 1999-2014
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