Select ListView Item on KeyPress
-
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.
-
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.
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 -
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 -
I've the same issue, did you implemented the Algo to search a specific item on keys down, if so kindly guide me!! Abdullah