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. C#
  4. Detecting key pressed on parent/childs MDI forms

Detecting key pressed on parent/childs MDI forms

Scheduled Pinned Locked Moved C#
helploungelearning
4 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.
  • D Offline
    D Offline
    dsovino
    wrote on last edited by
    #1

    Hi everyone, i would like to know if there's anyway I can detect a key pressed.:doh: I know there exists the KeyDown and KeyPress events on every control, but i would like to know if theres any way I can detect these events in general, instead of checking these events on all the controls of my application. I'm using a Parent Mdi Form containing lots of child forms, and of course this forms have lots of controls as well. I tried to apply this on the Parent Form's key events, but nothing. I bet there's a simple way to get this done. Please help. Thanks a lot for your time folks. daniel

    A 1 Reply Last reply
    0
    • D dsovino

      Hi everyone, i would like to know if there's anyway I can detect a key pressed.:doh: I know there exists the KeyDown and KeyPress events on every control, but i would like to know if theres any way I can detect these events in general, instead of checking these events on all the controls of my application. I'm using a Parent Mdi Form containing lots of child forms, and of course this forms have lots of controls as well. I tried to apply this on the Parent Form's key events, but nothing. I bet there's a simple way to get this done. Please help. Thanks a lot for your time folks. daniel

      A Offline
      A Offline
      Amjath Rahman
      wrote on last edited by
      #2

      hi daniel, for each form u have a property called kypreview, make this as true and then add keypress or keydown event to that form, so all the key press event come that function first and then goes to corresponding control i hope this will solve ur problem With Regards Amjath

      D D 2 Replies Last reply
      0
      • A Amjath Rahman

        hi daniel, for each form u have a property called kypreview, make this as true and then add keypress or keydown event to that form, so all the key press event come that function first and then goes to corresponding control i hope this will solve ur problem With Regards Amjath

        D Offline
        D Offline
        dsovino
        wrote on last edited by
        #3

        It worked just by applying it on the Parent Form. Thanx a lot!! :laugh: daniel

        1 Reply Last reply
        0
        • A Amjath Rahman

          hi daniel, for each form u have a property called kypreview, make this as true and then add keypress or keydown event to that form, so all the key press event come that function first and then goes to corresponding control i hope this will solve ur problem With Regards Amjath

          D Offline
          D Offline
          dengboo
          wrote on last edited by
          #4

          hey Amjath, perhaps you have little misunderstanding of the question.;) to daniel, I think it's the question about how to bind key events in a simple way. As it mentioned above, there're too many child forms in the parent form, and you don't want to bind the key event in each child form. Thinking of this, if there's a base form called ControlEx (or something else), and it contains the override method of OnKeyPress, OnKeyUp, etc, things will be simpler when all the child forms inheritted from ControlEx not from System.Windows.Froms.UserControl.

          --------------------------------- Believe what you saw!

          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