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_Key Up(object sender, System.EventArg s e)
{
MessageBox.Show ("keyboard button pressed!");
}
Following is the code to load the frmTestBaby
private void menuItem2_Click (object sender, System.EventArg s e)
{
frmTBaby frmTestBaby = new frmTBaby();
frmTestBaby.Mdi Parent = this;
frmTestBaby.Sho w();
}
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.Sho w(); but it did not work.
regards 8 4937
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.EventArg s e)
{
frmTBaby frmTestBaby = new frmTBaby();
frmTestBaby.Mdi Parent = this;
frmTestBaby.Sho w();
frmTestBaby.Key Up += new
System.Windows. Forms.KeyEventH andler
(this.frmTestBa by_KeyUp);
}
2. Add the code to the frmTestParent form to handle the
event.
private void frmTestBaby_Key Up(object sender,
System.Windows. Forms.KeyEventA rgs e)
{
MessageBox("Eve nt 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.c om/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_Key Up(object sender,
System.EventArg s e) { MessageBox.Show ("keyboard button
pressed!"); } Following is the code to load the frmTestBaby
private void menuItem2_Click (object sender,
System.EventArg s e) { frmTBaby frmTestBaby = new
frmTBaby(); frmTestBaby.Mdi Parent = this; frmTestBaby.Sho w(); }
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.Sh ow(); 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.mic rosoft.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.EventArg s e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Mdi Parent = this; frmTestBaby.Sho w();
frmTestBaby.Key Up += new System.Windows. Forms.KeyEventH andler (this.frmTestBa by_KeyUp); }
2. Add the code to the frmTestParent form to handle the event.
private void frmTestBaby_Key Up(object sender, System.Windows. Forms.KeyEventA rgs e) { MessageBox("Eve nt 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.c om/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_Key Up(object sender, System.EventArg s e) { MessageBox.Show ("keyboard button pressed!"); } Following is the code to load the frmTestBaby
private void menuItem2_Click (object sender, System.EventArg s e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Mdi Parent = this; frmTestBaby.Sho w(); }
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.Sh ow(); 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.Loa d event instead of the KeyUp event.
Try the following code:
private void menuItem2_Click (object sender,
System.EventArg s e)
{
frmTBaby frmTestBaby = new frmTBaby();
frmTestBaby.Loa d += new System.EventHan dler
(this.frmTestBa by_Load);
frmTestBaby.Mdi Parent = this;
frmTestBaby.Sho w();
}
private void frmTestBaby_Loa d(object sender,
System.EventArg s 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.c om/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.mic rosoft.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.EventArg s e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Mdi Parent = this; frmTestBaby.Sho w();
frmTestBaby.Key Up += new System.Windows. Forms.KeyEventH andler (this.frmTestBa by_KeyUp); }
2. Add the code to the frmTestParent form to handle
the event.
private void frmTestBaby_Key Up(object sender, System.Windows. Forms.KeyEventA rgs e) { MessageBox("Eve nt 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.c om/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_Key Up(object sender, System.EventArg s e) > { > MessageBox.Show ("keyboard button pressed!"); > } >Following is the code to load the frmTestBaby > >private void menuItem2_Click (object sender, System.EventArg s e) > { > frmTBaby frmTestBaby = new frmTBaby(); > frmTestBaby.Mdi Parent = this; > frmTestBaby.Sho w(); > } > >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.Sh ow(); 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.mic rosoft.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.Loa d event instead of the KeyUp event.
Try the following code:
private void menuItem2_Click (object sender, System.EventArg s e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Loa d += new System.EventHan dler (this.frmTestBa by_Load); frmTestBaby.Mdi Parent = this; frmTestBaby.Sho w(); }
private void frmTestBaby_Loa d(object sender, System.EventArg s 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.c om/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.mic rosoft.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.EventArg s e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Mdi Parent = this; frmTestBaby.Sho w();
frmTestBaby.Key Up += new System.Windows. Forms.KeyEventH andler (this.frmTestBa by_KeyUp); }
2. Add the code to the frmTestParent form to handle the event.
private void frmTestBaby_Key Up(object sender, System.Windows. Forms.KeyEventA rgs e) { MessageBox("Eve nt 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.c om/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_Key Up(object sender, System.EventArg s e) > { > MessageBox.Show ("keyboard button pressed!"); > } >Following is the code to load the frmTestBaby > >private void menuItem2_Click (object sender, System.EventArg s e) > { > frmTBaby frmTestBaby = new frmTBaby(); > frmTestBaby.Mdi Parent = this; > frmTestBaby.Sho w(); > } > >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.Sh ow(); 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.KeyEventA rgs e)
{
MessageBox.Show ("From TextBox1_KeyUp" );
this.OnKeyUp(e) ; // Raise the onKeyUp event
}
private void frmBabyTest_Key Up(object sender,
System.Windows. Forms.KeyEventA rgs e)
{
MessageBox.Show ("from frmBabyTest_Key Up");
}
Don't forget to add this to the InitializeCompo nent() or
frmBabyTest constructor:
this.KeyUp += new System.Windows. Forms.KeyEventH andler
(this. frmBabyTest_Key Up);
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.c om/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.mic rosoft.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.Loa d event instead of the KeyUp event.
Try the following code:
private void menuItem2_Click (object sender, System.EventArg s e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Loa d += new System.EventHan dler (this.frmTestBa by_Load); frmTestBaby.Mdi Parent = this; frmTestBaby.Sho w(); }
private void frmTestBaby_Loa d(object sender, System.EventArg s 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.c om/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.mic rosoft.com> wrote
in message news:<056b01c3b acc$50eefc40
$a*******@phx.g bl>... >> 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.EventArg s e) >> { >> frmTBaby frmTestBaby = new frmTBaby(); >> frmTestBaby.Mdi Parent = this; >> frmTestBaby.Sho w(); >> >> frmTestBaby.Key Up += new >> System.Windows. Forms.KeyEventH andler >> (this.frmTestBa by_KeyUp); >> } >> >> 2. Add the code to the frmTestParent form to handle the >> event. >> >> private void frmTestBaby_Key Up(object sender, >> System.Windows. Forms.KeyEventA rgs e) >> { >> MessageBox("Eve nt 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.c om/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_Key Up(object sender, System.EventArg s e) >> > { >> > MessageBox.Show ("keyboard button pressed!"); >> > } >> >Following is the code to load the frmTestBaby >> > >> >private void menuItem2_Click (object sender, System.EventArg s e) >> > { >> > frmTBaby frmTestBaby = new frmTBaby(); >> > frmTestBaby.Mdi Parent = this; >> > frmTestBaby.Sho w(); >> > } >> > >> >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.Sh ow(); 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(o bject sender, System.Windows. Forms.KeyEventA rgs 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.mic rosoft.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.KeyEventA rgs e) { MessageBox.Show ("From TextBox1_KeyUp" ); this.OnKeyUp(e) ; // Raise the onKeyUp event }
private void frmBabyTest_Key Up(object sender, System.Windows. Forms.KeyEventA rgs e) { MessageBox.Show ("from frmBabyTest_Key Up"); }
Don't forget to add this to the InitializeCompo nent() or frmBabyTest constructor:
this.KeyUp += new System.Windows. Forms.KeyEventH andler (this. frmBabyTest_Key Up);
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.c om/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.mic rosoft.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.Loa d event instead of the KeyUp event.
Try the following code:
private void menuItem2_Click (object sender, System.EventArg s e) { frmTBaby frmTestBaby = new frmTBaby(); frmTestBaby.Loa d += new System.EventHan dler (this.frmTestBa by_Load); frmTestBaby.Mdi Parent = this; frmTestBaby.Sho w(); }
private void frmTestBaby_Loa d(object sender, System.EventArg s 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.c om/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.mic rosoft.com> wrote in message news:<056b01c3b acc$50eefc40 $a*******@phx.g bl>... >> 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.EventArg s e) >> { >> frmTBaby frmTestBaby = new frmTBaby(); >> frmTestBaby.Mdi Parent = this; >> frmTestBaby.Sho w(); >> >> frmTestBaby.Key Up += new >> System.Windows. Forms.KeyEventH andler >> (this.frmTestBa by_KeyUp); >> } >> >> 2. Add the code to the frmTestParent form to handle the >> event. >> >> private void frmTestBaby_Key Up(object sender, >> System.Windows. Forms.KeyEventA rgs e) >> { >> MessageBox("Eve nt 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.c om/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_Key Up(object sender, System.EventArg s e) >> > { >> > MessageBox.Show ("keyboard button pressed!"); >> > } >> >Following is the code to load the frmTestBaby >> > >> >private void menuItem2_Click (object sender, System.EventArg s e) >> > { >> > frmTBaby frmTestBaby = new frmTBaby(); >> > frmTestBaby.Mdi Parent = this; >> > frmTestBaby.Sho w(); >> > } >> > >> >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.Sh ow(); 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.c om/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.KeyEventA rgs e){ MessageBox.Sho w("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.mic rosoft.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.KeyEventA rgs e) { MessageBox.Show ("From TextBox1_KeyUp" ); this.OnKeyUp(e) ; // Raise the onKeyUp event }
private void frmBabyTest_Key Up(object sender, System.Windows. Forms.KeyEventA rgs e) { MessageBox.Show ("from frmBabyTest_Key Up"); }
Don't forget to add this to the InitializeCompo nent()
or frmBabyTest constructor:
this.KeyUp += new System.Windows. Forms.KeyEventH andler (this. frmBabyTest_Key Up);
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.c om/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.mic rosoft.com> wrote
in message news:<02ca01c3b b62$2c13cc70
$a*******@phx.g bl>... >> 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.Loa d event instead of the KeyUp event. >> >> Try the following code: >> >> private void menuItem2_Click (object sender, >> System.EventArg s e) >> { >> frmTBaby frmTestBaby = new frmTBaby(); >> frmTestBaby.Loa d += new System.EventHan dler >> (this.frmTestBa by_Load); >> frmTestBaby.Mdi Parent = this; >> frmTestBaby.Sho w(); >> } >> >> private void frmTestBaby_Loa d(object sender, >> System.EventArg s 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.c om/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.mic rosoft.com>
wrote in >> message news:<056b01c3b acc$50eefc40 $a*******@phx.g bl>... >> >> 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.EventArg s e) >> >> { >> >> frmTBaby frmTestBaby = new frmTBaby(); >> >> frmTestBaby.Mdi Parent = this; >> >> frmTestBaby.Sho w(); >> >> >> >> frmTestBaby.Key Up += new >> >> System.Windows. Forms.KeyEventH andler >> >> (this.frmTestBa by_KeyUp); >> >> } >> >> >> >> 2. Add the code to the frmTestParent form to
handle the >> >> event. >> >> >> >> private void frmTestBaby_Key Up(object sender, >> >> System.Windows. Forms.KeyEventA rgs e) >> >> { >> >> MessageBox("Eve nt 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.c om/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_Key Up(object sender, System.EventArg s e) >> >> > { >> >> > MessageBox.Show ("keyboard
button pressed!"); >> >> > } >> >> >Following is the code to load the frmTestBaby >> >> > >> >> >private void menuItem2_Click (object sender, System.EventArg s e) >> >> > { >> >> > frmTBaby frmTestBaby =
new frmTBaby(); >> >> > frmTestBaby.Mdi Parent =
this; >> >> > frmTestBaby.Sho w(); >> >> > } >> >> > >> >> >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.Sh ow(); but it did not work. >> >> > >> >> >regards >> >> >. >> >> > >> >. >> > >. > .
Thank you very much Thomas. Its working now.
"Thomas Ha [MSFT]" <th*@online.mic rosoft.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.c om/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.KeyEventA rgs e){ MessageBox.Sho w("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.mic rosoft.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.KeyEventA rgs e) { MessageBox.Show ("From TextBox1_KeyUp" ); this.OnKeyUp(e) ; // Raise the onKeyUp event }
private void frmBabyTest_Key Up(object sender, System.Windows. Forms.KeyEventA rgs e) { MessageBox.Show ("from frmBabyTest_Key Up"); }
Don't forget to add this to the InitializeCompo nent() or frmBabyTest constructor:
this.KeyUp += new System.Windows. Forms.KeyEventH andler (this. frmBabyTest_Key Up);
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.c om/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.mic rosoft.com> wrote in message news:<02ca01c3b b62$2c13cc70 $a*******@phx.g bl>... >> 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.Loa d event instead of the KeyUp event. >> >> Try the following code: >> >> private void menuItem2_Click (object sender, >> System.EventArg s e) >> { >> frmTBaby frmTestBaby = new frmTBaby(); >> frmTestBaby.Loa d += new System.EventHan dler >> (this.frmTestBa by_Load); >> frmTestBaby.Mdi Parent = this; >> frmTestBaby.Sho w(); >> } >> >> private void frmTestBaby_Loa d(object sender, >> System.EventArg s 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.c om/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.mic rosoft.com> wrote in >> message news:<056b01c3b acc$50eefc40 $a*******@phx.g bl>... >> >> 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.EventArg s e) >> >> { >> >> frmTBaby frmTestBaby = new frmTBaby(); >> >> frmTestBaby.Mdi Parent = this; >> >> frmTestBaby.Sho w(); >> >> >> >> frmTestBaby.Key Up += new >> >> System.Windows. Forms.KeyEventH andler >> >> (this.frmTestBa by_KeyUp); >> >> } >> >> >> >> 2. Add the code to the frmTestParent form to handle the >> >> event. >> >> >> >> private void frmTestBaby_Key Up(object sender, >> >> System.Windows. Forms.KeyEventA rgs e) >> >> { >> >> MessageBox("Eve nt 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.c om/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_Key Up(object sender, System.EventArg s e) >> >> > { >> >> > MessageBox.Show ("keyboard button pressed!"); >> >> > } >> >> >Following is the code to load the frmTestBaby >> >> > >> >> >private void menuItem2_Click (object sender, System.EventArg s e) >> >> > { >> >> > frmTBaby frmTestBaby = new frmTBaby(); >> >> > frmTestBaby.Mdi Parent = this; >> >> > frmTestBaby.Sho w(); >> >> > } >> >> > >> >> >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.Sh ow(); 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 ChildForm();
this.AddOwnedForm (child);
|
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 put, there is an MDIForm and a child form.
The MDIForm does the usual from within its constructor...
this.IsMdiContainer = true;
Form2 frm = new Form2();
|
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 not handle any event
beyond that. What event should I use to handle Mdichild closing
event. (i'm looking for mdichild form event, not event related to
forms by name)
MTIA,
|
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 handler.
public class frmMain
{
private System.Windows.Forms.Button btnClickMe;
|
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 seperate objects
which we can and must control. On these com objects I added the events
via AddHandler. This is working great, I can see that my threads are
raising events through the com object.
| |
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 buttons in a groupbox, and have
the appearence set to button
|
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 doesn't exist (the
menu name is mfavorites).
Thanks.
Darin
*** Sent via Developersdex http://www.developersdex.com ***
|
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 correctly. (E.G. I have form1 and form2 as the child forms, form1 is active. I left click anywhere on form2 and the focus and z-index changes). This works correctly.
However, if I right click on the non-active form the focus and z-index does not change. ...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |