473,396 Members | 1,702 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,396 software developers and data experts.

KeyDown Event not firing at all...?! Please help!

i'm working with visual studio 2005 and have a solution with 16
projects in it.

this specific application has a base form with other forms added to it
at any area of the application that the user navigates to through the
nav panel

anyways, on one of the forms i'm attempting to have a configuration
setting set to a hotkey press for the user to be able to reset a
feature with a hotkey combination

in design mode, i had the form that i want the event hooked to
selected, go to the events properties, double click the keydown event
then add this code:

private void form_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys.Shift | Keys.R))
{
MessageBox.Show("SHIFT + R");
}
}

obviously the hotkey combination is the shift key + the R key.
however, nothing happens when i debug this application and test the key
combination on this form.

i also set a breakpoint on the "if statement" to see if it hits and it
does not even hit the if statement in the keydown event

any and all help would be greatly appreciated, thank you.

mike

Mar 29 '06 #1
4 13485
Set your form's KeyPreview property to true.

Mar 30 '06 #2
Set your form's KeyPreview property to true.

Mar 30 '06 #3
thank you, that makes sense, although the form i am working with has no
such property.
i think it has to do with the parent form that it's inheriting from.
i'll figure it out, you got me on the right track.

thank you very much for help.

Mar 30 '06 #4
i found the keypreview property of the parent form but even when i set
it to true, the events on the child form are not being raised...?

i'm at a loss. i set breakpoints on the keyevents that i set on the
child form and no matter what, they're not being hit.

here is my code:

in the formload:

//i set the parent's property to true on that actual form also, but
this is just to verify for good measure
this.ParentForm.KeyPreview = true;
this.KeyDown += new KeyEventHandler(ReportModule_KeyDown);

then in the ReportModule_KeyDown event:

void ReportModule_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode.ToString() == "F")
{
this.ParentForm.KeyPreview = false;
MessageBox.Show("reportmodule keydown");
}
}

and nothing. i set a breakpoint at the start of this event and it isn't
hitting that breakpoint at all when i do Alt+F. i also tried it for
keydown period, no if statement
and it also didn't get hit...?

Apr 7 '06 #5

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

Similar topics

0
by: CoderOfBugs | last post by:
I am developing an IE Toolbar that has a combo box. The combox box doesn't fire the KeyDown event when the {Backspace} key is pressed. Very strange. The event fires for {Delete}, {Space}, {CTRL},...
3
by: Peter S | last post by:
I have function : System::Void Form1_KeyDown(Object* sender, KeyEventArgs* e) but this: this->KeyDown += new KeyEventHandler(this, Form1_KeyDown); doesnt work.. how I can change it to run?...
4
by: Anne | last post by:
hie again, i have 3 textbox and i would like the user to go to the next textbox by pressing the 'ENTER' key. i have tried using this: Private Sub txtRequestor_KeyDown(ByVal sender As...
2
by: Phil Galey | last post by:
I have a Panel control docked on all sides on a form and the panel control contains a PictureBox. I'm using the KeyDown event of the form to respond to the and keys for resizing the image and the...
4
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my...
9
by: runner7 | last post by:
Can anyone help me with how to programmatically fire a keydown event in Firefox?
3
by: MLM450 | last post by:
I have a control that handles the KeyDown event but it does not seem to execute when a combination of keys is pressed - like CTRL+Z. If I press CTRL, it executes. If I press Z, it executes. But the...
1
by: bigijoseph | last post by:
Please help : page load event is not firing. -------------------------------------------------------------------------------- Hi, I am a new to .net. I am trying to learn it. I tried the...
5
by: T | last post by:
Hi, How do I fire the KeyDown event in Managed VC++? I am getting a compile error saying "event does not have a raise method". Please help. regards, T
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.