469,604 Members | 2,272 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,604 developers. It's quick & easy.

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 6471

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by (Pete Cresswell) | last post: by
reply views Thread by Govindaraj K | last post: by
1 post views Thread by Emil | last post: by
4 posts views Thread by Tony | last post: by
4 posts views Thread by Anne | last post: by
7 posts views Thread by Bob Achgill | last post: by
4 posts views Thread by jxiang | last post: by
3 posts views Thread by MLM450 | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.