By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

Redirect or capture keydown event from a child form

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a

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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.