472,127 Members | 1,432 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 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 6696

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

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.