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. Keys [modified]

Keys [modified]

Scheduled Pinned Locked Moved C#
question
7 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.
  • M Offline
    M Offline
    mihksoft
    wrote on last edited by
    #1

    Hy, I have the following code put in the protected override OnKeyDown to a RichTextBox: switch (e.KeyCode) { case Keys.Tab: case Keys.Enter: { autocomplete(_defaultColor); e.Handled = true; break; } } and the autocomplete method: private void autocomplete(Color defaultColor) { for (int i = 0; i < 1; i++) { SendKeys.SendWait("{BACKSPACE}"); } SendKeys.SendWait("public"); } 1.Run the application and press "p" then press ENTER. 2.Run the application and press "p" then press TAB. In both cases the effect is different but is the same code for both cases. Can somebody give me an explication? -- modified at 8:58 Tuesday 9th October, 2007

    L 1 Reply Last reply
    0
    • M mihksoft

      Hy, I have the following code put in the protected override OnKeyDown to a RichTextBox: switch (e.KeyCode) { case Keys.Tab: case Keys.Enter: { autocomplete(_defaultColor); e.Handled = true; break; } } and the autocomplete method: private void autocomplete(Color defaultColor) { for (int i = 0; i < 1; i++) { SendKeys.SendWait("{BACKSPACE}"); } SendKeys.SendWait("public"); } 1.Run the application and press "p" then press ENTER. 2.Run the application and press "p" then press TAB. In both cases the effect is different but is the same code for both cases. Can somebody give me an explication? -- modified at 8:58 Tuesday 9th October, 2007

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, unless you set KeyEventArgs.SuppressKeyPress true, there will be a KeyPress event, which will act differently for ENTER and TAB. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


      M 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, unless you set KeyEventArgs.SuppressKeyPress true, there will be a KeyPress event, which will act differently for ENTER and TAB. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


        M Offline
        M Offline
        Martin 0
        wrote on last edited by
        #3

        Hello Luc,

        Luc Pattyn wrote:

        set KeyEventArgs.SuppressKeyPress true

        very interesting! Do you also know a .Net 1.1 solution for that problem?

        All the best, Martin

        L 1 Reply Last reply
        0
        • M Martin 0

          Hello Luc,

          Luc Pattyn wrote:

          set KeyEventArgs.SuppressKeyPress true

          very interesting! Do you also know a .Net 1.1 solution for that problem?

          All the best, Martin

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi Martin, sorry I don't know a replacement for KeyEventArgs.SuppressKeyPress other than adding specific code in one or both event handlers. I stopped using .NET 1.x completely. Greetings,

          Luc Pattyn [Forum Guidelines] [My Articles]


          this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


          M 1 Reply Last reply
          0
          • L Luc Pattyn

            Hi Martin, sorry I don't know a replacement for KeyEventArgs.SuppressKeyPress other than adding specific code in one or both event handlers. I stopped using .NET 1.x completely. Greetings,

            Luc Pattyn [Forum Guidelines] [My Articles]


            this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


            M Offline
            M Offline
            Martin 0
            wrote on last edited by
            #5

            Hello Luc, But isn't there allways the problem, that the "Tab" leeds to loosing the Focus of the Control?

            Luc Pattyn wrote:

            I stopped using .NET 1.x completely.

            Oh no! The last one (apart from me) left the ship! :)

            All the best, Martin

            L 1 Reply Last reply
            0
            • M Martin 0

              Hello Luc, But isn't there allways the problem, that the "Tab" leeds to loosing the Focus of the Control?

              Luc Pattyn wrote:

              I stopped using .NET 1.x completely.

              Oh no! The last one (apart from me) left the ship! :)

              All the best, Martin

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Martin# wrote:

              But isn't there allways the problem, that the "Tab" leeds to loosing the Focus of the Control?

              There was and is a solution to these by using one of Control.IsInputChar and Control.ProcessCmdKey :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


              M 1 Reply Last reply
              0
              • L Luc Pattyn

                Martin# wrote:

                But isn't there allways the problem, that the "Tab" leeds to loosing the Focus of the Control?

                There was and is a solution to these by using one of Control.IsInputChar and Control.ProcessCmdKey :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


                M Offline
                M Offline
                Martin 0
                wrote on last edited by
                #7

                Excellent! :rose:

                All the best, Martin

                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