Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,

I have built a control in the style of Excels grid in which a collection of cells is presented to the user to scroll and select etc.

When i key up or down the current row moves up and down similar to a list box, if i hold the down key the control performs the action of scrolling through the items quickly.

The speed of this however appears fixed. I was wondering what is restricting this as there is no flickering or anything indicating that the PC is struggling to render the table.

Is it the amount of processing being carried out or a standard in .Net fixing the speed of event firing when holding down a key etc?

Thanks George
Posted
Updated 4-Jan-11 22:32pm
v2
Comments
Nuri Ismail 5-Jan-11 4:33am    
Removed bold.

Does it stop immediately when you release the key?
If not, then it is processing.
If so, then it may be you key repeat speed - a windows feature you cna change in control panel!

What you may need to do is work from the keydown and keyup events with a timer and scroll in larger increments the longer the key is kept down - and ignore the keypress event while you are doing it!
 
Share this answer
 
Comments
grwithey 5-Jan-11 4:48am    
Ah that makes sense, it does stop immediately when released which would indicate it is the repeat speed.

That sounds like a good way of overcoming this thanks for the help.
Espen Harlinn 5-Jan-11 4:55am    
5+ Good idea about the keyboard handling
JF2015 5-Jan-11 4:56am    
Good. Have my 5.
JOAT-MON 5-Jan-11 4:58am    
Nice test, nice solution. +5
Nuri Ismail 5-Jan-11 5:05am    
Good call.
My guess is that you are repainting to often.

OriginalGriffs idea "What you may need to do is work from the keydown and keyup events with a timer and scroll in larger increments the longer the key is kept down - and ignore the keypress event while you are doing it!" is a good one.

If you just invalidate the area that needs repainting in your input handling you will probably see an improvement.

Regards
Espen Harlinn
 
Share this answer
 
Comments
grwithey 5-Jan-11 5:09am    
It currently only calls a refresh once during the key press and only draws the items that are visible area of the control.

I have tested the control to 1 million entries and it scrolls the same speed so i think OriginalGiffs suggestion is a good idea.

Thanks George

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900