Call in each class the function of the base:
Class1 and 2:
protected override void OnKeyPress(System.Object sender,
System.Windows.Forms.KeyPressEventArgs e)
{ base.OnKeyPress(sender, e); }
By the way, if you want to use the OnKeyPress method of
System.Windows.Forms.Form, it has no argument "sender" !
Class Main:
protected virtual void OnKeyPress(System.Object sender,
System.Windows.Forms.KeyPressEventArgs e)
{ /* Do Nothing */ }
protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{ OnKeyPress(this, e); base.OnKeyPress(e); }
Jaga
"~toki" <pedorro77.hotmail.com> schrieb im Newsbeitrag
news:uZ**************@TK2MSFTNGP10.phx.gbl...
How can i take the control of the key events in Class2 ?
This is the code snipped that i'd tried (after try some others):
public class Main : System.Windows.Forms.Form
{
protected virtual void OnKeyPress(System.Object sender,
System.Windows.Forms.KeyPressEventArgs e) { /* Do Nothing */ }
}
public class Class1 : Main
{
protected override void OnKeyPress(System.Object sender,
System.Windows.Forms.KeyPressEventArgs e) { /* Do Nothing */ }
}
public class Class2 : Class1
{
protected override void OnKeyPress(System.Object sender,
System.Windows.Forms.KeyPressEventArgs e) { /* DO SOMETHING */ }
}