Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. KeyDown method question

KeyDown method question

Scheduled Pinned Locked Moved Visual Basic
questionhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sa_runner
    wrote on last edited by
    #1

    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.

    N 1 Reply Last reply
    0
    • S sa_runner

      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.

      N Offline
      N Offline
      nlarson11
      wrote on last edited by
      #2

      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 form2

      private sub ChildKeyDown(sChar as string) handles mForm2.ChildKeyDown
      msgbox("the key pressed was: " & sChar
      end sub

      'add logic to show form2
      end class

      public 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

      G 1 Reply Last reply
      0
      • N nlarson11

        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 form2

        private sub ChildKeyDown(sChar as string) handles mForm2.ChildKeyDown
        msgbox("the key pressed was: " & sChar
        end sub

        'add logic to show form2
        end class

        public 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

        G Offline
        G Offline
        GuyThiebaut
        wrote on last edited by
        #3

        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.
        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups