KeyDown method question
-
I have an app where I have a parent and child form. How can I capture the key that is pressed (if any) on the child form? I tried the keydown method, but when I run the program, it will not enter the method when I type a key. Any help would be appreciated. Thanks.
-
I have an app where I have a parent and child form. How can I capture the key that is pressed (if any) on the child form? I tried the keydown method, but when I run the program, it will not enter the method when I type a key. Any help would be appreciated. Thanks.
the 2 forms are completely independent of each other even though you started one from another. event or delegate is the proper way to go. the event example(done by memory - syntax is mostly good)
public class form1
private withevents mForm2 as form2private sub ChildKeyDown(sChar as string) handles mForm2.ChildKeyDown
msgbox("the key pressed was: " & sChar
end sub'add logic to show form2
end classpublic class form2
event ChildKeyDown(sChar as string)private textbox1\_keydown(sender , e ) handles textbox1.keydown raiseevent childkeydown(e.keychar) end sub
end class
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
-
the 2 forms are completely independent of each other even though you started one from another. event or delegate is the proper way to go. the event example(done by memory - syntax is mostly good)
public class form1
private withevents mForm2 as form2private sub ChildKeyDown(sChar as string) handles mForm2.ChildKeyDown
msgbox("the key pressed was: " & sChar
end sub'add logic to show form2
end classpublic class form2
event ChildKeyDown(sChar as string)private textbox1\_keydown(sender , e ) handles textbox1.keydown raiseevent childkeydown(e.keychar) end sub
end class
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
Just wanted to say thanks for this post - this is an area that is new to me and you have answered a question I had. 5 Stars :) Guy
You always pass failure on the way to success.