J
Jim
I have extended a DataGrid, and made a KeyInput event so I could handle
keypresses in the grid.
Here's the relevant code:
[in the namespace of the class, but not in the class]
public delegate void KeyboardInputDelegate(Keys keyData);
[class member]
public event KeyboardInputDelegate KeyboardInput;
[overridden function to notify event]
protected override bool ProcessDialogKey(Keys keyData)
{
bool result = base.ProcessDialogKey(keyData);
KeyboardInput(keyData); // <-- tell event subscribers
return result;
}
If I don't create a handler for this event, then the program will crash
when it calls KeyboardInput(keyData);, presumably because it's calling a
function that doesn't exist.
So if a handler has not been assigned, how does one keep the program
from attemptinf to call an unhandled event?
Any help appreciated!
Thanks
keypresses in the grid.
Here's the relevant code:
[in the namespace of the class, but not in the class]
public delegate void KeyboardInputDelegate(Keys keyData);
[class member]
public event KeyboardInputDelegate KeyboardInput;
[overridden function to notify event]
protected override bool ProcessDialogKey(Keys keyData)
{
bool result = base.ProcessDialogKey(keyData);
KeyboardInput(keyData); // <-- tell event subscribers
return result;
}
If I don't create a handler for this event, then the program will crash
when it calls KeyboardInput(keyData);, presumably because it's calling a
function that doesn't exist.
So if a handler has not been assigned, how does one keep the program
from attemptinf to call an unhandled event?
Any help appreciated!
Thanks