hy,
I have an mdi application, i create a child form and I want to know
when a button is pressed while that child form is loaded.
I have this code:
private void frmTestBaby_KeyUp(object sender, System.EventArgs e)
{
MessageBox.Show("keyboard button pressed!");
}
Following is the code to load the frmTestBaby
private void menuItem2_Click(object sender, System.EventArgs e)
{
frmTBaby frmTestBaby = new frmTBaby();
frmTestBaby.MdiParent = this;
frmTestBaby.Show();
}
Can someone help out to how to get the event raised KeyUp for the
child form frmTestBaby.
Please note that I have also tried activating the child form after
frmTestBaby.Show(); but it did not work.
regards 8 4898
Hi,
If I understand you correctly, you want to raise an event
from the child form so the parent form can receive the
event. If that's what you want, here's what you can try.
1. Add the event handler to the frmTestParent form:
private void menuItem2_Click(object sender,
System.EventArgs e)
{
frmTBaby frmTestBaby = new frmTBaby();
frmTestBaby.MdiParent = this;
frmTestBaby.Show();
frmTestBaby.KeyUp += new
System.Windows.Forms.KeyEventHandler
(this.frmTestBaby_KeyUp);
}
2. Add the code to the frmTestParent form to handle the
event.
private void frmTestBaby_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
MessageBox("Event Receive from Parent: KeyUp was "
e.KeyCode);
}
This will only work if the frmTestBaby form does not have
a control (ie: text box) that will receive the KeyUp
event before the form. Otherwise, the control has to
raise the event so the form will receive it.
Hope this helps,
Thomas
Disclaimer:
This posting is provided "AS IS" with no warranties, and
confers no rights. "Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm" -----Original Message----- hy, I have an mdi application, i create a child form and I
want to knowwhen a button is pressed while that child form is loaded. I have this code:
private void frmTestBaby_KeyUp(object sender,
System.EventArgs e) { MessageBox.Show("keyboard button
pressed!"); } Following is the code to load the frmTestBaby
private void menuItem2_Click(object sender,
System.EventArgs e) { frmTBaby frmTestBaby = new
frmTBaby(); frmTestBaby.MdiParent = this; frmTestBaby.Show(); }
Can someone help out to how to get the event raised
KeyUp for thechild form frmTestBaby. Please note that I have also tried activating the child
form afterfrmTestBaby.Show(); but it did not work.
regards .
Thanks Thomas, I tried the code but still it did not work :( any other
idea please share with me
"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in message news:<05****************************@phx.gbl>... Hi,
If I understand you correctly, you want to raise an event from the child form so the parent form can receive the event. If that's what you want, here's what you can try.
1. Add the event handler to the frmTestParent form:
private void menuItem2_Click(object sender, System.EventArgs e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.MdiParent = this; frmTestBaby.Show();
frmTestBaby.KeyUp += new System.Windows.Forms.KeyEventHandler (this.frmTestBaby_KeyUp); }
2. Add the code to the frmTestParent form to handle the event.
private void frmTestBaby_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox("Event Receive from Parent: KeyUp was " e.KeyCode); }
This will only work if the frmTestBaby form does not have a control (ie: text box) that will receive the KeyUp event before the form. Otherwise, the control has to raise the event so the form will receive it.
Hope this helps, Thomas
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm" -----Original Message----- hy, I have an mdi application, i create a child form and I want to knowwhen a button is pressed while that child form is loaded. I have this code:
private void frmTestBaby_KeyUp(object sender, System.EventArgs e) { MessageBox.Show("keyboard button pressed!"); } Following is the code to load the frmTestBaby
private void menuItem2_Click(object sender, System.EventArgs e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.MdiParent = this; frmTestBaby.Show(); }
Can someone help out to how to get the event raised KeyUp for thechild form frmTestBaby. Please note that I have also tried activating the child form afterfrmTestBaby.Show(); but it did not work.
regards .
You have to make sure the controls inside frmTestBaby
form do not receive the KeyUp event first. This may not
be possible. Also, clicking on the button does not raise
a KeyUp event.
I read your original question again. If you just want
the parent to receive an event when the child form is
loaded, you should have the parent capture the
frmTestBaby.Load event instead of the KeyUp event.
Try the following code:
private void menuItem2_Click(object sender,
System.EventArgs e)
{
frmTBaby frmTestBaby = new frmTBaby();
frmTestBaby.Load += new System.EventHandler
(this.frmTestBaby_Load);
frmTestBaby.MdiParent = this;
frmTestBaby.Show();
}
private void frmTestBaby_Load(object sender,
System.EventArgs e)
{
MessageBox.Show("child form loaded");
}
Please let me know if I've misunderstood your question
again. I hope this will point you to the right path.
Thomas
Disclaimer:
This posting is provided "AS IS" with no warranties, and
confers no rights. "Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm" -----Original Message----- Thanks Thomas, I tried the code but still it did not
work :( any otheridea please share with me
"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in
message news:<05****************************@phx.gbl>... Hi,
If I understand you correctly, you want to raise an
event from the child form so the parent form can receive the event. If that's what you want, here's what you can
try. 1. Add the event handler to the frmTestParent form:
private void menuItem2_Click(object sender, System.EventArgs e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.MdiParent = this; frmTestBaby.Show();
frmTestBaby.KeyUp += new System.Windows.Forms.KeyEventHandler (this.frmTestBaby_KeyUp); }
2. Add the code to the frmTestParent form to handle
the event.
private void frmTestBaby_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox("Event Receive from Parent: KeyUp
was " e.KeyCode); }
This will only work if the frmTestBaby form does not
have a control (ie: text box) that will receive the KeyUp event before the form. Otherwise, the control has to raise the event so the form will receive it.
Hope this helps, Thomas
Disclaimer: This posting is provided "AS IS" with no warranties,
and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm" >-----Original Message----- >hy, >I have an mdi application, i create a child form and
I want to know >when a button is pressed while that child form is
loaded. >I have this code: > >private void frmTestBaby_KeyUp(object sender, System.EventArgs e) > { > MessageBox.Show("keyboard button pressed!"); > } >Following is the code to load the frmTestBaby > >private void menuItem2_Click(object sender, System.EventArgs e) > { > frmTBaby frmTestBaby = new frmTBaby(); > frmTestBaby.MdiParent = this; > frmTestBaby.Show(); > } > >Can someone help out to how to get the event raised KeyUp for the >child form frmTestBaby. >Please note that I have also tried activating the
child form after >frmTestBaby.Show(); but it did not work. > >regards >. > .
<<< I need to raise event on child form keyup >>>.
my code is not working that i mentioned in first post. I also tried ur
approach for the parent form to recieve the event keyup and raise it,
this is also not working. just to check for events in child forms, i
tried to define a mouse click event on the child form, it is perfectly
working.
I dnt understand that why keyup event is not working on child form of
an mdi application. is it a limitation on c#?
could u plz help.
regards
Arif
"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in message news:<02****************************@phx.gbl>... You have to make sure the controls inside frmTestBaby form do not receive the KeyUp event first. This may not be possible. Also, clicking on the button does not raise a KeyUp event.
I read your original question again. If you just want the parent to receive an event when the child form is loaded, you should have the parent capture the frmTestBaby.Load event instead of the KeyUp event.
Try the following code:
private void menuItem2_Click(object sender, System.EventArgs e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Load += new System.EventHandler (this.frmTestBaby_Load); frmTestBaby.MdiParent = this; frmTestBaby.Show(); }
private void frmTestBaby_Load(object sender, System.EventArgs e) { MessageBox.Show("child form loaded"); }
Please let me know if I've misunderstood your question again. I hope this will point you to the right path.
Thomas
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm"
-----Original Message----- Thanks Thomas, I tried the code but still it did not work :( any otheridea please share with me
"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in message news:<05****************************@phx.gbl>... Hi,
If I understand you correctly, you want to raise an event from the child form so the parent form can receive the event. If that's what you want, here's what you can try. 1. Add the event handler to the frmTestParent form:
private void menuItem2_Click(object sender, System.EventArgs e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.MdiParent = this; frmTestBaby.Show();
frmTestBaby.KeyUp += new System.Windows.Forms.KeyEventHandler (this.frmTestBaby_KeyUp); }
2. Add the code to the frmTestParent form to handle the event.
private void frmTestBaby_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox("Event Receive from Parent: KeyUp was " e.KeyCode); }
This will only work if the frmTestBaby form does not have a control (ie: text box) that will receive the KeyUp event before the form. Otherwise, the control has to raise the event so the form will receive it.
Hope this helps, Thomas
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm" >-----Original Message----- >hy, >I have an mdi application, i create a child form and I want to know >when a button is pressed while that child form is loaded. >I have this code: > >private void frmTestBaby_KeyUp(object sender, System.EventArgs e) > { > MessageBox.Show("keyboard button pressed!"); > } >Following is the code to load the frmTestBaby > >private void menuItem2_Click(object sender, System.EventArgs e) > { > frmTBaby frmTestBaby = new frmTBaby(); > frmTestBaby.MdiParent = this; > frmTestBaby.Show(); > } > >Can someone help out to how to get the event raised KeyUp for the >child form frmTestBaby. >Please note that I have also tried activating the child form after >frmTestBaby.Show(); but it did not work. > >regards >. > .
Hi Arif,
Sorry, I totally misunderstood what you were trying to
do. All you wanted to do was to detect a KeyUp event in
the frmBabyTest whenever a key is pressed on any controls
inside the frmBabyTest form, correct?
As I mentioned in my first response, the controls inside
the frmBabyTest form will receive the KeyUp event first.
As a result, the frmBabyTest never receives it.
Therefore, the control, that receives the KeyUp event,
needs to raise it to the frmBabyTest form.
For example:
private void TextBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
MessageBox.Show("From TextBox1_KeyUp");
this.OnKeyUp(e); // Raise the onKeyUp event
}
private void frmBabyTest_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
MessageBox.Show("from frmBabyTest_KeyUp");
}
Don't forget to add this to the InitializeComponent() or
frmBabyTest constructor:
this.KeyUp += new System.Windows.Forms.KeyEventHandler
(this. frmBabyTest_KeyUp);
This will work. I tested it out on my test MDI app.
Thomas
Disclaimer:
This posting is provided "AS IS" with no warranties, and
confers no rights. "Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm" -----Original Message----- <<< I need to raise event on child form keyup >>>. my code is not working that i mentioned in first post. I
also tried urapproach for the parent form to recieve the event keyup
and raise it,this is also not working. just to check for events in
child forms, itried to define a mouse click event on the child form,
it is perfectlyworking. I dnt understand that why keyup event is not working on
child form ofan mdi application. is it a limitation on c#? could u plz help. regards Arif "Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in
message news:<02****************************@phx.gbl>... You have to make sure the controls inside frmTestBaby form do not receive the KeyUp event first. This may
not be possible. Also, clicking on the button does not
raise a KeyUp event.
I read your original question again. If you just want the parent to receive an event when the child form is loaded, you should have the parent capture the frmTestBaby.Load event instead of the KeyUp event.
Try the following code:
private void menuItem2_Click(object sender, System.EventArgs e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Load += new System.EventHandler (this.frmTestBaby_Load); frmTestBaby.MdiParent = this; frmTestBaby.Show(); }
private void frmTestBaby_Load(object sender, System.EventArgs e) { MessageBox.Show("child form loaded"); }
Please let me know if I've misunderstood your question again. I hope this will point you to the right path.
Thomas
Disclaimer: This posting is provided "AS IS" with no warranties,
and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm"
>-----Original Message----- >Thanks Thomas, I tried the code but still it did not work :( any other >idea please share with me > >"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote
in message news:<056b01c3bacc$50eefc40
$a*******@phx.gbl>... >> Hi, >> >> If I understand you correctly, you want to raise an event >> from the child form so the parent form can receive
the >> event. If that's what you want, here's what you
can try. >> >> 1. Add the event handler to the frmTestParent form: >> >> private void menuItem2_Click(object sender, >> System.EventArgs e) >> { >> frmTBaby frmTestBaby = new frmTBaby(); >> frmTestBaby.MdiParent = this; >> frmTestBaby.Show(); >> >> frmTestBaby.KeyUp += new >> System.Windows.Forms.KeyEventHandler >> (this.frmTestBaby_KeyUp); >> } >> >> 2. Add the code to the frmTestParent form to handle the >> event. >> >> private void frmTestBaby_KeyUp(object sender, >> System.Windows.Forms.KeyEventArgs e) >> { >> MessageBox("Event Receive from Parent: KeyUp was " >> e.KeyCode); >> } >> >> This will only work if the frmTestBaby form does
not have >> a control (ie: text box) that will receive the
KeyUp >> event before the form. Otherwise, the control has
to >> raise the event so the form will receive it. >> >> Hope this helps, >> Thomas >> >> Disclaimer: >> This posting is provided "AS IS" with no
warranties, and >> confers no rights. "Use of included script samples
are >> subject to the terms specified at >> http://www.microsoft.com/info/cpyright.htm" >> >> >> >> >-----Original Message----- >> >hy, >> >I have an mdi application, i create a child form
and I want to know >> >when a button is pressed while that child form is loaded. >> >I have this code: >> > >> >private void frmTestBaby_KeyUp(object sender, System.EventArgs e) >> > { >> > MessageBox.Show("keyboard button pressed!"); >> > } >> >Following is the code to load the frmTestBaby >> > >> >private void menuItem2_Click(object sender, System.EventArgs e) >> > { >> > frmTBaby frmTestBaby = new frmTBaby(); >> > frmTestBaby.MdiParent = this; >> > frmTestBaby.Show(); >> > } >> > >> >Can someone help out to how to get the event
raised KeyUp for the >> >child form frmTestBaby. >> >Please note that I have also tried activating the child form after >> >frmTestBaby.Show(); but it did not work. >> > >> >regards >> >. >> > >. > .
hy Thomas, I think that I could not communicate well. I neeed to raise
KeyUp event OF the CHILD Form. For example if the child form name is
frmBaby then I need to have some action on
frmBaby_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
MessageBox.Show("Key up on child form frmBaby");
}
I DO NOT want to raise events on the controls of child form now.
can you tell me how to do this? or can you guide me if i could find
some documents detailing this or in worse case if C# is able to handle
child form events?
i hope you know what i mean.
regards
"Thomas Ha" <th*@online.microsoft.com> wrote in message news:<02****************************@phx.gbl>... Hi Arif,
Sorry, I totally misunderstood what you were trying to do. All you wanted to do was to detect a KeyUp event in the frmBabyTest whenever a key is pressed on any controls inside the frmBabyTest form, correct?
As I mentioned in my first response, the controls inside the frmBabyTest form will receive the KeyUp event first. As a result, the frmBabyTest never receives it. Therefore, the control, that receives the KeyUp event, needs to raise it to the frmBabyTest form.
For example:
private void TextBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox.Show("From TextBox1_KeyUp"); this.OnKeyUp(e); // Raise the onKeyUp event }
private void frmBabyTest_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox.Show("from frmBabyTest_KeyUp"); }
Don't forget to add this to the InitializeComponent() or frmBabyTest constructor:
this.KeyUp += new System.Windows.Forms.KeyEventHandler (this. frmBabyTest_KeyUp);
This will work. I tested it out on my test MDI app. Thomas
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm"
-----Original Message----- <<< I need to raise event on child form keyup >>>. my code is not working that i mentioned in first post. I also tried urapproach for the parent form to recieve the event keyup and raise it,this is also not working. just to check for events in child forms, itried to define a mouse click event on the child form, it is perfectlyworking. I dnt understand that why keyup event is not working on child form ofan mdi application. is it a limitation on c#? could u plz help. regards Arif "Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in message news:<02****************************@phx.gbl>... You have to make sure the controls inside frmTestBaby form do not receive the KeyUp event first. This may not be possible. Also, clicking on the button does not raise a KeyUp event.
I read your original question again. If you just want the parent to receive an event when the child form is loaded, you should have the parent capture the frmTestBaby.Load event instead of the KeyUp event.
Try the following code:
private void menuItem2_Click(object sender, System.EventArgs e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Load += new System.EventHandler (this.frmTestBaby_Load); frmTestBaby.MdiParent = this; frmTestBaby.Show(); }
private void frmTestBaby_Load(object sender, System.EventArgs e) { MessageBox.Show("child form loaded"); }
Please let me know if I've misunderstood your question again. I hope this will point you to the right path.
Thomas
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm"
>-----Original Message----- >Thanks Thomas, I tried the code but still it did not work :( any other >idea please share with me > >"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in message news:<056b01c3bacc$50eefc40 $a*******@phx.gbl>... >> Hi, >> >> If I understand you correctly, you want to raise an event >> from the child form so the parent form can receive the >> event. If that's what you want, here's what you can try. >> >> 1. Add the event handler to the frmTestParent form: >> >> private void menuItem2_Click(object sender, >> System.EventArgs e) >> { >> frmTBaby frmTestBaby = new frmTBaby(); >> frmTestBaby.MdiParent = this; >> frmTestBaby.Show(); >> >> frmTestBaby.KeyUp += new >> System.Windows.Forms.KeyEventHandler >> (this.frmTestBaby_KeyUp); >> } >> >> 2. Add the code to the frmTestParent form to handle the >> event. >> >> private void frmTestBaby_KeyUp(object sender, >> System.Windows.Forms.KeyEventArgs e) >> { >> MessageBox("Event Receive from Parent: KeyUp was " >> e.KeyCode); >> } >> >> This will only work if the frmTestBaby form does not have >> a control (ie: text box) that will receive the KeyUp >> event before the form. Otherwise, the control has to >> raise the event so the form will receive it. >> >> Hope this helps, >> Thomas >> >> Disclaimer: >> This posting is provided "AS IS" with no warranties, and >> confers no rights. "Use of included script samples are >> subject to the terms specified at >> http://www.microsoft.com/info/cpyright.htm" >> >> >> >> >-----Original Message----- >> >hy, >> >I have an mdi application, i create a child form and I want to know >> >when a button is pressed while that child form is loaded. >> >I have this code: >> > >> >private void frmTestBaby_KeyUp(object sender, System.EventArgs e) >> > { >> > MessageBox.Show("keyboard button pressed!"); >> > } >> >Following is the code to load the frmTestBaby >> > >> >private void menuItem2_Click(object sender, System.EventArgs e) >> > { >> > frmTBaby frmTestBaby = new frmTBaby(); >> > frmTestBaby.MdiParent = this; >> > frmTestBaby.Show(); >> > } >> > >> >Can someone help out to how to get the event raised KeyUp for the >> >child form frmTestBaby. >> >Please note that I have also tried activating the child form after >> >frmTestBaby.Show(); but it did not work. >> > >> >regards >> >. >> > >. > .
Hi Arif,
I understand that's what you want. The last sample does
exactly what you want. You need to understand that if
your frmBaby has any controls (which it does), the
controls will receive the KeyUp event first if any are in
focus. Therefore your frmBaby never receive the event.
That's why each of your controls need to raise the KeyUp
event (frmBaby.KeyUp(e)) so the frmBaby will receive it.
You mentioned earlier that the click event works fine.
That's because you can click on an area of the form where
no controls are located. As a result, the frmBaby
receives the onclick event first instead of any controls.
Here's a test you can do. Remove all of your controls or
disable all of them in the frmBaby. Then capture the
KeyUp event in the frmBaby, you'll find out that it will
work without raising a KeyUp event from any controls.
Hope this will clarify the issue!
Thomas
Disclaimer:
This posting is provided "AS IS" with no warranties, and
confers no rights. "Use of included script samples are
subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm" -----Original Message----- hy Thomas, I think that I could not communicate well. I
neeed to raiseKeyUp event OF the CHILD Form. For example if the child
form name isfrmBaby then I need to have some action on frmBaby_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e){ MessageBox.Show("Key up on child form frmBaby"); } I DO NOT want to raise events on the controls of child
form now.can you tell me how to do this? or can you guide me if i
could findsome documents detailing this or in worse case if C# is
able to handlechild form events?
i hope you know what i mean. regards
"Thomas Ha" <th*@online.microsoft.com> wrote in message
news:<02****************************@phx.gbl>... Hi Arif,
Sorry, I totally misunderstood what you were trying to do. All you wanted to do was to detect a KeyUp event
in the frmBabyTest whenever a key is pressed on any
controls inside the frmBabyTest form, correct?
As I mentioned in my first response, the controls
inside the frmBabyTest form will receive the KeyUp event
first. As a result, the frmBabyTest never receives it. Therefore, the control, that receives the KeyUp event, needs to raise it to the frmBabyTest form.
For example:
private void TextBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox.Show("From TextBox1_KeyUp"); this.OnKeyUp(e); // Raise the onKeyUp event }
private void frmBabyTest_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox.Show("from frmBabyTest_KeyUp"); }
Don't forget to add this to the InitializeComponent()
or frmBabyTest constructor:
this.KeyUp += new System.Windows.Forms.KeyEventHandler (this. frmBabyTest_KeyUp);
This will work. I tested it out on my test MDI app. Thomas
Disclaimer: This posting is provided "AS IS" with no warranties,
and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm"
>-----Original Message----- ><<< I need to raise event on child form keyup >>>. >my code is not working that i mentioned in first
post. I also tried ur >approach for the parent form to recieve the event
keyup and raise it, >this is also not working. just to check for events in child forms, i >tried to define a mouse click event on the child
form, it is perfectly >working. >I dnt understand that why keyup event is not working
on child form of >an mdi application. is it a limitation on c#? >could u plz help. >regards >Arif >"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote
in message news:<02ca01c3bb62$2c13cc70
$a*******@phx.gbl>... >> You have to make sure the controls inside
frmTestBaby >> form do not receive the KeyUp event first. This
may not >> be possible. Also, clicking on the button does not raise >> a KeyUp event. >> >> I read your original question again. If you just
want >> the parent to receive an event when the child form
is >> loaded, you should have the parent capture the >> frmTestBaby.Load event instead of the KeyUp event. >> >> Try the following code: >> >> private void menuItem2_Click(object sender, >> System.EventArgs e) >> { >> frmTBaby frmTestBaby = new frmTBaby(); >> frmTestBaby.Load += new System.EventHandler >> (this.frmTestBaby_Load); >> frmTestBaby.MdiParent = this; >> frmTestBaby.Show(); >> } >> >> private void frmTestBaby_Load(object sender, >> System.EventArgs e) >> { >> MessageBox.Show("child form loaded"); >> } >> >> Please let me know if I've misunderstood your
question >> again. I hope this will point you to the right
path. >> >> Thomas >> >> Disclaimer: >> This posting is provided "AS IS" with no
warranties, and >> confers no rights. "Use of included script samples
are >> subject to the terms specified at >> http://www.microsoft.com/info/cpyright.htm" >> >> >> >-----Original Message----- >> >Thanks Thomas, I tried the code but still it did
not work :( any other >> >idea please share with me >> > >> >"Thomas Ha [MSFT]" <th*@online.microsoft.com>
wrote in >> message news:<056b01c3bacc$50eefc40 $a*******@phx.gbl>... >> >> Hi, >> >> >> >> If I understand you correctly, you want to raise
an event >> >> from the child form so the parent form can
receive the >> >> event. If that's what you want, here's what you can try. >> >> >> >> 1. Add the event handler to the frmTestParent
form: >> >> >> >> private void menuItem2_Click(object sender, >> >> System.EventArgs e) >> >> { >> >> frmTBaby frmTestBaby = new frmTBaby(); >> >> frmTestBaby.MdiParent = this; >> >> frmTestBaby.Show(); >> >> >> >> frmTestBaby.KeyUp += new >> >> System.Windows.Forms.KeyEventHandler >> >> (this.frmTestBaby_KeyUp); >> >> } >> >> >> >> 2. Add the code to the frmTestParent form to
handle the >> >> event. >> >> >> >> private void frmTestBaby_KeyUp(object sender, >> >> System.Windows.Forms.KeyEventArgs e) >> >> { >> >> MessageBox("Event Receive from Parent:
KeyUp was " >> >> e.KeyCode); >> >> } >> >> >> >> This will only work if the frmTestBaby form does not have >> >> a control (ie: text box) that will receive the KeyUp >> >> event before the form. Otherwise, the control
has to >> >> raise the event so the form will receive it. >> >> >> >> Hope this helps, >> >> Thomas >> >> >> >> Disclaimer: >> >> This posting is provided "AS IS" with no warranties, and >> >> confers no rights. "Use of included script
samples are >> >> subject to the terms specified at >> >> http://www.microsoft.com/info/cpyright.htm" >> >> >> >> >> >> >> >> >-----Original Message----- >> >> >hy, >> >> >I have an mdi application, i create a child
form and >> I >> want to know >> >> >when a button is pressed while that child form
is loaded. >> >> >I have this code: >> >> > >> >> >private void frmTestBaby_KeyUp(object sender, System.EventArgs e) >> >> > { >> >> > MessageBox.Show("keyboard
button pressed!"); >> >> > } >> >> >Following is the code to load the frmTestBaby >> >> > >> >> >private void menuItem2_Click(object sender, System.EventArgs e) >> >> > { >> >> > frmTBaby frmTestBaby =
new frmTBaby(); >> >> > frmTestBaby.MdiParent =
this; >> >> > frmTestBaby.Show(); >> >> > } >> >> > >> >> >Can someone help out to how to get the event raised KeyUp for the >> >> >child form frmTestBaby. >> >> >Please note that I have also tried activating
the >> child >> form after >> >> >frmTestBaby.Show(); but it did not work. >> >> > >> >> >regards >> >> >. >> >> > >> >. >> > >. > .
Thank you very much Thomas. Its working now.
"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in message news:<10*****************************@phx.gbl>... Hi Arif,
I understand that's what you want. The last sample does exactly what you want. You need to understand that if your frmBaby has any controls (which it does), the controls will receive the KeyUp event first if any are in focus. Therefore your frmBaby never receive the event. That's why each of your controls need to raise the KeyUp event (frmBaby.KeyUp(e)) so the frmBaby will receive it.
You mentioned earlier that the click event works fine. That's because you can click on an area of the form where no controls are located. As a result, the frmBaby receives the onclick event first instead of any controls.
Here's a test you can do. Remove all of your controls or disable all of them in the frmBaby. Then capture the KeyUp event in the frmBaby, you'll find out that it will work without raising a KeyUp event from any controls.
Hope this will clarify the issue! Thomas
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm"
-----Original Message----- hy Thomas, I think that I could not communicate well. I neeed to raiseKeyUp event OF the CHILD Form. For example if the child form name isfrmBaby then I need to have some action on frmBaby_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e){ MessageBox.Show("Key up on child form frmBaby"); } I DO NOT want to raise events on the controls of child form now.can you tell me how to do this? or can you guide me if i could findsome documents detailing this or in worse case if C# is able to handlechild form events?
i hope you know what i mean. regards
"Thomas Ha" <th*@online.microsoft.com> wrote in message news:<02****************************@phx.gbl>... Hi Arif,
Sorry, I totally misunderstood what you were trying to do. All you wanted to do was to detect a KeyUp event in the frmBabyTest whenever a key is pressed on any controls inside the frmBabyTest form, correct?
As I mentioned in my first response, the controls inside the frmBabyTest form will receive the KeyUp event first. As a result, the frmBabyTest never receives it. Therefore, the control, that receives the KeyUp event, needs to raise it to the frmBabyTest form.
For example:
private void TextBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox.Show("From TextBox1_KeyUp"); this.OnKeyUp(e); // Raise the onKeyUp event }
private void frmBabyTest_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox.Show("from frmBabyTest_KeyUp"); }
Don't forget to add this to the InitializeComponent() or frmBabyTest constructor:
this.KeyUp += new System.Windows.Forms.KeyEventHandler (this. frmBabyTest_KeyUp);
This will work. I tested it out on my test MDI app. Thomas
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm"
>-----Original Message----- ><<< I need to raise event on child form keyup >>>. >my code is not working that i mentioned in first post. I also tried ur >approach for the parent form to recieve the event keyup and raise it, >this is also not working. just to check for events in child forms, i >tried to define a mouse click event on the child form, it is perfectly >working. >I dnt understand that why keyup event is not working on child form of >an mdi application. is it a limitation on c#? >could u plz help. >regards >Arif >"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in message news:<02ca01c3bb62$2c13cc70 $a*******@phx.gbl>... >> You have to make sure the controls inside frmTestBaby >> form do not receive the KeyUp event first. This may not >> be possible. Also, clicking on the button does not raise >> a KeyUp event. >> >> I read your original question again. If you just want >> the parent to receive an event when the child form is >> loaded, you should have the parent capture the >> frmTestBaby.Load event instead of the KeyUp event. >> >> Try the following code: >> >> private void menuItem2_Click(object sender, >> System.EventArgs e) >> { >> frmTBaby frmTestBaby = new frmTBaby(); >> frmTestBaby.Load += new System.EventHandler >> (this.frmTestBaby_Load); >> frmTestBaby.MdiParent = this; >> frmTestBaby.Show(); >> } >> >> private void frmTestBaby_Load(object sender, >> System.EventArgs e) >> { >> MessageBox.Show("child form loaded"); >> } >> >> Please let me know if I've misunderstood your question >> again. I hope this will point you to the right path. >> >> Thomas >> >> Disclaimer: >> This posting is provided "AS IS" with no warranties, and >> confers no rights. "Use of included script samples are >> subject to the terms specified at >> http://www.microsoft.com/info/cpyright.htm" >> >> >> >-----Original Message----- >> >Thanks Thomas, I tried the code but still it did not work :( any other >> >idea please share with me >> > >> >"Thomas Ha [MSFT]" <th*@online.microsoft.com> wrote in >> message news:<056b01c3bacc$50eefc40 $a*******@phx.gbl>... >> >> Hi, >> >> >> >> If I understand you correctly, you want to raise an event >> >> from the child form so the parent form can receive the >> >> event. If that's what you want, here's what you can try. >> >> >> >> 1. Add the event handler to the frmTestParent form: >> >> >> >> private void menuItem2_Click(object sender, >> >> System.EventArgs e) >> >> { >> >> frmTBaby frmTestBaby = new frmTBaby(); >> >> frmTestBaby.MdiParent = this; >> >> frmTestBaby.Show(); >> >> >> >> frmTestBaby.KeyUp += new >> >> System.Windows.Forms.KeyEventHandler >> >> (this.frmTestBaby_KeyUp); >> >> } >> >> >> >> 2. Add the code to the frmTestParent form to handle the >> >> event. >> >> >> >> private void frmTestBaby_KeyUp(object sender, >> >> System.Windows.Forms.KeyEventArgs e) >> >> { >> >> MessageBox("Event Receive from Parent: KeyUp was " >> >> e.KeyCode); >> >> } >> >> >> >> This will only work if the frmTestBaby form does not have >> >> a control (ie: text box) that will receive the KeyUp >> >> event before the form. Otherwise, the control has to >> >> raise the event so the form will receive it. >> >> >> >> Hope this helps, >> >> Thomas >> >> >> >> Disclaimer: >> >> This posting is provided "AS IS" with no warranties, and >> >> confers no rights. "Use of included script samples are >> >> subject to the terms specified at >> >> http://www.microsoft.com/info/cpyright.htm" >> >> >> >> >> >> >> >> >-----Original Message----- >> >> >hy, >> >> >I have an mdi application, i create a child form and >> I >> want to know >> >> >when a button is pressed while that child form is loaded. >> >> >I have this code: >> >> > >> >> >private void frmTestBaby_KeyUp(object sender, System.EventArgs e) >> >> > { >> >> > MessageBox.Show("keyboard button pressed!"); >> >> > } >> >> >Following is the code to load the frmTestBaby >> >> > >> >> >private void menuItem2_Click(object sender, System.EventArgs e) >> >> > { >> >> > frmTBaby frmTestBaby = new frmTBaby(); >> >> > frmTestBaby.MdiParent = this; >> >> > frmTestBaby.Show(); >> >> > } >> >> > >> >> >Can someone help out to how to get the event raised KeyUp for the >> >> >child form frmTestBaby. >> >> >Please note that I have also tried activating the >> child >> form after >> >> >frmTestBaby.Show(); but it did not work. >> >> > >> >> >regards >> >> >. >> >> > >> >. >> > >. > .
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Frank T. Clark |
last post by:
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...
|
by: Martin Douglas |
last post by:
Hey guys, maybe someone can help me with some MDI issues I have. A
co-worker asked me a very simple question, one that I blew off as trivial,
and it has become a time-consuming issue.
Simply...
|
by: al |
last post by:
Hi,
I have MDI form with 4 mdichild forms. I would like to enable Windows
menu-item as more than 1 mdichild form loads. The problem i'm having
is when MdiChildActivate event is raised, it does...
|
by: jimcolli |
last post by:
I have a parent form with a menu button that has a handler.
I want to call this same handler when a button on a child form is
clicked.
I have this simplified code in the main form's Load...
|
by: daan |
last post by:
Hello,
I have a problem and I can't get the solution for it :(
I have a com dll, which i imported as a reference. The com object is
part of a class which is multithreaded and will create...
|
by: Peted |
last post by:
Hi
Im using c# express edition 2005
I have an MDI form, where i load multiple child forms from a dll i
create, using reflection and late binding
The child forms have multiple radio...
|
by: Darin |
last post by:
I have a parent form that has a menu. I then have a child form on the
menu. From the child form I need to change the parent form's menu - how
can i do that? I tried me.parent.mfavorites, but that...
|
by: daffurankan |
last post by:
hai,
could i call the child form events like (closing ,load, activate,closed) .
]from the parent mdi form.
Reply asap.
Waitng for reply ANKAN Rastogi
|
by: Joe Wyrwas |
last post by:
My main program is a Multiple Document Interface (MDI). I create and show 2 or more child forms inside the MDI parent. If I left click on the child forms, the focus and Z-index will change...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
| |