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

Redirect or capture keydown event from a child form

How do I redirect or capture keydown events in a parent form from a child
form?

I have a main form which displays another informational form marked
"SizableToolWindow".

Form child = new ChildForm();

this.AddOwnedForm (child);

child.Show();

I don't want the child form to be active just to show information. I do want
the user to be able to move the form and change the size. How do I make sure
that the information from any keydown events goes to the parent form?

I have programmed extensively in C using the Win32 API but I am only
starting with C#.
Nov 15 '05 #1
3 6905

You could create an event in the child. The parent
subscribes to it.
Whenever the keydown is fired on the child, you should
fire your event. Since the main form will be subcribing to
it, it will also get the events.

-Wasu
-----Original Message-----
How do I redirect or capture keydown events in a parent form from a childform?

I have a main form which displays another informational form marked"SizableToolWindow".

Form child = new ChildForm();

this.AddOwnedForm (child);

child.Show();

I don't want the child form to be active just to show information. I do wantthe user to be able to move the form and change the size. How do I make surethat the information from any keydown events goes to the parent form?
I have programmed extensively in C using the Win32 API but I am onlystarting with C#.
.

Nov 15 '05 #2
Try adding a KeyEventHandler when you create the child form:

//Create child
private void mnuFileNew_Click(object sender, System.EventArgs e)
{
frmChild child = new frmChild();
frmChild.MdiParent = this;
frmChild.Show();
//Raise keydown events to this form
frmChild.KeyDown +=new KeyEventHandler(frmChild_KeyDown);
}
//Child form KeyDown event raised to parent
private void frmChild_KeyDown(object sender, KeyEventArgs e)
{
//process key here
}
"Frank T. Clark" <Cl***@JMIsoftware.com> wrote in message
news:#8**************@TK2MSFTNGP10.phx.gbl...
How do I redirect or capture keydown events in a parent form from a child
form?

I have a main form which displays another informational form marked
"SizableToolWindow".

Form child = new ChildForm();

this.AddOwnedForm (child);

child.Show();

I don't want the child form to be active just to show information. I do want the user to be able to move the form and change the size. How do I make sure that the information from any keydown events goes to the parent form?

I have programmed extensively in C using the Win32 API but I am only
starting with C#.

Nov 15 '05 #3
Thank you. I always say. "The answer is simple... Once you know the answer."
:)

"Tim Matteson" <Ma********@hotmail.com> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
Try adding a KeyEventHandler when you create the child form:

//Create child
private void mnuFileNew_Click(object sender, System.EventArgs e)
{
frmChild child = new frmChild();
frmChild.MdiParent = this;
frmChild.Show();
//Raise keydown events to this form
frmChild.KeyDown +=new KeyEventHandler(frmChild_KeyDown);
}
//Child form KeyDown event raised to parent
private void frmChild_KeyDown(object sender, KeyEventArgs e)
{
//process key here
}
"Frank T. Clark" <Cl***@JMIsoftware.com> wrote in message
news:#8**************@TK2MSFTNGP10.phx.gbl...
How do I redirect or capture keydown events in a parent form from a child form?

I have a main form which displays another informational form marked
"SizableToolWindow".

Form child = new ChildForm();

this.AddOwnedForm (child);

child.Show();

I don't want the child form to be active just to show information. I do

want
the user to be able to move the form and change the size. How do I make

sure
that the information from any keydown events goes to the parent form?

I have programmed extensively in C using the Win32 API but I am only
starting with C#.


Nov 15 '05 #4

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

Similar topics

7
by: (Pete Cresswell) | last post by:
I've got KeyDown coding and it fires when other keys are pressed, but when Enter is pressed, nothing. I'd like to support the (standard?) Windows behavior of executing DblClick processing when...
0
by: Govindaraj K | last post by:
Hi, I am working with MDI form , In a child form i am unable to move the cursor to previous control using the Shift + Tab combination in KEYDOWN Event procedure. Even i set the tabStop property...
1
by: Emil | last post by:
I've written a simple application. It consists of main window, menu and a label. I added event handler to the main form (KeyDown), so when I push a key on the keyboard, then it's key code should be...
4
by: Tony | last post by:
I'm building a simple "breakout" style video-game, and I want keyboard control of the paddle. What I need is for an event handler to respond whenever a key is pressed, regardless of what the...
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...
7
by: Bob Achgill | last post by:
When I use the code for KeyPress to capture pressing a certain key for processing on a form with no Text Box it works. But when I try the same code on my application that has text boxes it does...
4
by: jxiang | last post by:
I created a child form that is much bigger than the MDI form in VB.Net. I am trying to capture the whole child form and save as an image or sent to printer. I tried to use BitBlt to capture the...
4
by: velasquez.m | last post by:
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...
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.