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. Is this a bug in .NET 2.0?

Is this a bug in .NET 2.0?

Scheduled Pinned Locked Moved C#
helpcsharpquestion
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.
  • A Offline
    A Offline
    adfgh75
    wrote on last edited by
    #1

    I'm developing an windows application in .NET 2.0 where the user is supposed to navigate around the application using the arrow keys(I'm using KeyDown event to handle user key input). My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed! Is this a bug and is there another way to do this? Thanks

    Vester

    S M 2 Replies Last reply
    0
    • A adfgh75

      I'm developing an windows application in .NET 2.0 where the user is supposed to navigate around the application using the arrow keys(I'm using KeyDown event to handle user key input). My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed! Is this a bug and is there another way to do this? Thanks

      Vester

      S Offline
      S Offline
      sam
      wrote on last edited by
      #2

      there is no such . you must be unable to handle event properly.elaborate more about your control's desired behaviour and what do you want

      1 Reply Last reply
      0
      • A adfgh75

        I'm developing an windows application in .NET 2.0 where the user is supposed to navigate around the application using the arrow keys(I'm using KeyDown event to handle user key input). My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed! Is this a bug and is there another way to do this? Thanks

        Vester

        M Offline
        M Offline
        Michael P Butler
        wrote on last edited by
        #3

        adfgh75 wrote:

        My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed!

        The key press is probably being handled by another control. Have you tried setting KeyPreview[^]to true

        Michael CP Blog [^] Development Blog [^]

        A 1 Reply Last reply
        0
        • M Michael P Butler

          adfgh75 wrote:

          My problem is that I want to use UserControls in my application but whenever I add my UserControls to my windows form the form don't recieve any KeyDown events when I press the arrows keys, however it reacts to any other keys being pressed!

          The key press is probably being handled by another control. Have you tried setting KeyPreview[^]to true

          Michael CP Blog [^] Development Blog [^]

          A Offline
          A Offline
          adfgh75
          wrote on last edited by
          #4

          Well yes, I have set KeyPreview to true on the form (and breakpoints to trace the event)and it still doesn't throw any KeyDown event when when I press the arrow keys, but it throws it when I press any other key. If I let the class inherit from Panel instead of UserControl or Control it works perfect. However I've discovered that if I override the ProcessCmdKey() function in the form and process the key pressed there instead it will work.

          .NET

          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