OK Folks, I am one confused puppy. Can someone please explain what the
difference is and when to use each.
I have a form with a button dropped onto it. Without actually doing anything
to the button, I next add the following code:
protected override void OnKeyDown(KeyEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.KeyCode.ToStr ing());
base.OnKeyDown(e);
}
When you press a key, it is not handled. If you change the tabstop property
of the form to false, the it is now handled. Why?
However, if I put the tabstop back to true and I add an keydown event
instead:
private void button1_KeyDown(object sender, KeyEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.KeyCode.ToStr ing());
}
When you press a key it is handled. What is happening that is different?
My understanding of what happens when you override a form method seems to be
shot to pieces.
So when should you override form methods and when should you use events?
Any clarification on this subject area would be most appreciated.
Thanks
Mike 3 1775
OK Slight clarification, (read the question before i post it.)
Can someone please explain what the difference is and when to use each.
I have a form with a button dropped onto it. Without actually doing anything
to the button, I next add the following code to the form:
protected override void OnKeyDown(KeyEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.KeyCode.ToStr ing());
base.OnKeyDown(e);
}
When you press a key, it is not handled. If you change the tabstop property
of the button to false, the key down event is now handled. Why?
However, if I put the tabstop property of the button back to true and I add
an keydown event
instead:
private void button1_KeyDown(object sender, KeyEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.KeyCode.ToStr ing());
}
When you press a key it is handled. What is happening that is different?
My understanding of what happens when you override a form method seems to be
shot to pieces.
So when should you override form methods and when should you use events?
Any clarification on this subject area would be most appreciated.
Thanks
Mike
Hi Publicjoe,
the OnKeyDown method you are overriding corresponds to the KeyDown event
of the form not of the button.
Regards Christof
"Publicjoe" <mi**@publicjoe.co.ukschrieb im Newsbeitrag
news:uD****************@TK2MSFTNGP02.phx.gbl...
OK Slight clarification, (read the question before i post it.)
Can someone please explain what the difference is and when to use each.
I have a form with a button dropped onto it. Without actually doing
anything
to the button, I next add the following code to the form:
protected override void OnKeyDown(KeyEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.KeyCode.ToStr ing());
base.OnKeyDown(e);
}
When you press a key, it is not handled. If you change the tabstop
property
of the button to false, the key down event is now handled. Why?
However, if I put the tabstop property of the button back to true and I
add an keydown event
instead:
private void button1_KeyDown(object sender, KeyEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.KeyCode.ToStr ing());
}
When you press a key it is handled. What is happening that is different?
My understanding of what happens when you override a form method seems to
be
shot to pieces.
So when should you override form methods and when should you use events?
Any clarification on this subject area would be most appreciated.
Thanks
Mike
whoops, I meant the keydown event of the form
"Christof Nordiek" <cn@nospam.dewrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi Publicjoe,
the OnKeyDown method you are overriding corresponds to the KeyDown event
of the form not of the button.
Regards Christof
"Publicjoe" <mi**@publicjoe.co.ukschrieb im Newsbeitrag
news:uD****************@TK2MSFTNGP02.phx.gbl...
>OK Slight clarification, (read the question before i post it.)
Can someone please explain what the difference is and when to use each.
I have a form with a button dropped onto it. Without actually doing anything to the button, I next add the following code to the form:
protected override void OnKeyDown(KeyEventArgs e) { System.Diagnostics.Debug.WriteLine(e.KeyCode.ToStr ing()); base.OnKeyDown(e); }
When you press a key, it is not handled. If you change the tabstop property of the button to false, the key down event is now handled. Why?
However, if I put the tabstop property of the button back to true and I add an keydown event instead:
private void button1_KeyDown(object sender, KeyEventArgs e) { System.Diagnostics.Debug.WriteLine(e.KeyCode.ToStr ing()); }
When you press a key it is handled. What is happening that is different?
My understanding of what happens when you override a form method seems to be shot to pieces.
So when should you override form methods and when should you use events?
Any clarification on this subject area would be most appreciated.
Thanks
Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JPRoot |
last post by:
Hi
I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
|
by: JPRoot |
last post by:
Hi M. Jeffrey Tan,
Just hopping you didn't forget me? :)
Thanks
JPRoot
----- \"Jeffrey Tan\" wrote: -----
|
by: bhavin |
last post by:
Hi,
Can someone point me to some good best practices kind of documentation on
use of events compared to method overriding.
Ex. In Windows Forms when should i have an event handler for Paint, and...
|
by: Ryan Joseph So |
last post by:
Hi,
Is it possible to override an event replacing its EventArgs w/ my own
event? like
this is native event
protected override void OnDropDownClosed(EventArgs e)
{
//code goes here...
}
|
by: Keith Smith |
last post by:
Could some one help me a little? I am trying to understand when/where you
would ever want to use "protected override..." code such as this. How is
this any different from creating a...
|
by: DotNetBBK |
last post by:
Hi,
I am using a custom text box, where I need to override TabSelection, as I
have to generate an event and based on that event, I need to do some
processing in other class, who is listening to...
|
by: bdeviled |
last post by:
I am deploying to a web environment that uses load balancing and to insure
that sessions persist across servers, the environment uses SQL to manage
sessions. The machine.config file determines how...
|
by: Publicjoe |
last post by:
OK Try again
Can someone please explain what the difference is and when to use each.
I have a form with a button dropped onto it. Without actually doing anything
to the button, I next add the...
|
by: Rob |
last post by:
I've constructed a user control inherited from ListView so I can handle and
respond to scrolling events (to keep 2 listviews scrolling in sync).
My user control includes an Overrides of WndProc...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
| |