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. Select ListView Item on KeyPress

Select ListView Item on KeyPress

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

    I am looking for a way to autoselect ListView Items on Key Press event based on the sorted column. The behaviour should be similar to Windows explorer. If one types the keys very fast the keys should be buffered and the buffer string should be compared with the sorted column. If the speed is slow, the buffer is cleared. Can somebody guide me to some article on this? I tried to google but to no avail. I know this is available on of-the-shelf ListView. But this works only for the first column. I need this on the sorted column.

    J 1 Reply Last reply
    0
    • M miah alom

      I am looking for a way to autoselect ListView Items on Key Press event based on the sorted column. The behaviour should be similar to Windows explorer. If one types the keys very fast the keys should be buffered and the buffer string should be compared with the sorted column. If the speed is slow, the buffer is cleared. Can somebody guide me to some article on this? I tried to google but to no avail. I know this is available on of-the-shelf ListView. But this works only for the first column. I need this on the sorted column.

      J Offline
      J Offline
      John Fisher
      wrote on last edited by
      #2

      Don't have an article for you, but here is a basic implementation description:

      Handle the KeyDown event for the appropriate control.
      If the last key press was not within the timeout period,
      then clear the "keys pressed" buffer (maybe a string builder).
      Add the typed key to your "keys pressed" buffer.
      Reset the keydown timer to the current time.
      Perform your comparison to select the appropriate item.

      Selecting an item is very straightforward, so that shouldn't be much of a problem. If you're not sure how to do the comparing, you can do it easily by looping through the items list and comparing the substrings manually. John
      "You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek. -- modified at 15:28 Tuesday 20th September, 2005

      M 1 Reply Last reply
      0
      • J John Fisher

        Don't have an article for you, but here is a basic implementation description:

        Handle the KeyDown event for the appropriate control.
        If the last key press was not within the timeout period,
        then clear the "keys pressed" buffer (maybe a string builder).
        Add the typed key to your "keys pressed" buffer.
        Reset the keydown timer to the current time.
        Perform your comparison to select the appropriate item.

        Selecting an item is very straightforward, so that shouldn't be much of a problem. If you're not sure how to do the comparing, you can do it easily by looping through the items list and comparing the substrings manually. John
        "You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek. -- modified at 15:28 Tuesday 20th September, 2005

        M Offline
        M Offline
        miah alom
        wrote on last edited by
        #3

        Thanks for your reply. This should work.

        A 1 Reply Last reply
        0
        • M miah alom

          Thanks for your reply. This should work.

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

          I've the same issue, did you implemented the Algo to search a specific item on keys down, if so kindly guide me!! Abdullah

          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