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. textbox autocomplete return character keypress problem

textbox autocomplete return character keypress problem

Scheduled Pinned Locked Moved C#
helpquestion
4 Posts 2 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.
  • K Offline
    K Offline
    Karl 2000
    wrote on last edited by
    #1

    Hi, I was using the return character to evaluate the input of a textbox via the keypress event. private void textBoxInput_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { e.Handled = true; } } After turning on autocomple the keypress event is no longer triggered when the pressed key is the return key. Does anyone know a way around this? Thanks

    Karl

    M K 2 Replies Last reply
    0
    • K Karl 2000

      Hi, I was using the return character to evaluate the input of a textbox via the keypress event. private void textBoxInput_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { e.Handled = true; } } After turning on autocomple the keypress event is no longer triggered when the pressed key is the return key. Does anyone know a way around this? Thanks

      Karl

      M Offline
      M Offline
      Mudsoad
      wrote on last edited by
      #2

      when you use autocomplete and choose a text from the autocomplete list, its sure that it wll not trigger the keypress event because you are not pressing keys onthe keyboard. try validating the text in the textbox again before you will use it.

      Signature has been encrypted

      K 1 Reply Last reply
      0
      • M Mudsoad

        when you use autocomplete and choose a text from the autocomplete list, its sure that it wll not trigger the keypress event because you are not pressing keys onthe keyboard. try validating the text in the textbox again before you will use it.

        Signature has been encrypted

        K Offline
        K Offline
        Karl 2000
        wrote on last edited by
        #3

        Thanks for your reply. It doesn't matter if the text is chosen from the autocomplete list or the person is typing in something completely new. The return key never fires a keypress event anymore. Every other key fires the event. The return key instead causes the text to be highlighted. I am not sure what you mean by validating the text in the textbox before using it. I currently do not validate the text, anything can be entered in the box. Thanks.

        Karl

        1 Reply Last reply
        0
        • K Karl 2000

          Hi, I was using the return character to evaluate the input of a textbox via the keypress event. private void textBoxInput_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { e.Handled = true; } } After turning on autocomple the keypress event is no longer triggered when the pressed key is the return key. Does anyone know a way around this? Thanks

          Karl

          K Offline
          K Offline
          Karl 2000
          wrote on last edited by
          #4

          After further investigation it turns out that auto complete only intercepts the keypress event for the return key. The keypress event gets fired appropriately with any other key. The other keyboard events such as keyup and keydown are unaffected by this issue so they can be used as a work around. If anyone knows more about this issue please reply.

          Karl

          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