473,320 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Override OnKeyPress Problem

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 */ }
}
Nov 15 '05 #1
2 4152
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 */ }
}

Nov 15 '05 #2
Thanks a lot for your time, it work!

"Jaga" <ja***@web.de> escribió en el mensaje
news:%2******************@TK2MSFTNGP12.phx.gbl...
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 */ }
}


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Fred Brown | last post by:
Hi, I want to cancel a certain key in JavaScript. To do so, I catch the event in OnKeyPress and cancel the default: <head> .... function f(evt) { var evt = (evt) ? evt : ((window.event) ?...
5
by: Albert Wagner | last post by:
I have included a file below that tests onKeyPress in Opera 7.11. I am getting peculiar behavior. When the file is first loaded, pressing the keypad + causes the textarea to get physically larger...
7
by: Kev | last post by:
I need to make some specific alterations to some JavaScript in webpages in order to comply with government guidelines on accessibility. Apparently, whenever the OnClick event is used, it must be...
4
by: Colin | last post by:
Hello all, I am working on a project using Windows Forms, and I ran into a bit of a snag... I need to be able to use keystrokes as shortcuts in the program, and I currently accomplish it using...
1
by: Steve | last post by:
I would like to override the IsInputKey function in order to trap the arrow up/down keys in the Key Events. I understand that arrow keys don't have a char representation and thus, hard to trap. ...
3
by: Robert Inder | last post by:
I am struggling to catch kestrokes within an Internet Explorer 6 window. My window happens to be displaying three frames, though I suspect a similar problem would arise with a single document. ...
1
by: vega80 | last post by:
Hi. I have a problem with assigning an onkeypress-function to dynamically created input-boxes.I want to put the content of an input-field into a tag-list when the user hits enter. This works...
4
by: Grant Merwitz | last post by:
Hi I am trying to implement the Microsoft Ajax.NET extensions to perform a lookup on a key press of a text box. What this will do is once a user enters a letter into the textbox, this will...
3
by: gjain12 | last post by:
Hi all, I am using the following code to disable the ctrl+a/c/v/x keys. <html> <head> <script language="JavaScript" type="text/javascript"> function disableCtrlKeyCombination(e) { //list...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.