Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello , I've got a question. With those codes everything is alright but when I hold down a key.
It goes like "A+A+A+" It keeps pressing the key multiple times.
How do I get "A+" instead of "A+A+A+"?


C#
private void gridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z)
            {
              
                gridView1.GetFocusedDataRow()["Shortcut"] =gridView1.GetFocusedDataRow()["Shortcut"]+ e.KeyCode.ToString()+"+";
            }

        }
Posted
Updated 17-Jul-14 21:59pm
v2

1 solution

That is the expected behaviour: it's call "Autorepeat" and it is exactly what is suppose to happen, so your user can hold down a key and get multiple instances of it: like holding down the "hyphen" button and getting a row of dashes.

If you want to stop it, you will need to handle the KeyUp event as well and do it yourself. Might be a little messy, particularly if they use the mouse to move elsewhere and come back...
 
Share this answer
 
Comments
Cenkay Vergili 18-Jul-14 4:29am    
Thanks and Yeah! I did the same a few minutes ago (KeyUp event) It worked. But as you said The mouse is a huge problem. I am so new to coding especially to DevExpress. DevEx has too many different methods , extensions.
The best Solution I could find was "Focused Data Row". As soon as I finish little problems I will go through to that. Thanks again.
OriginalGriff 18-Jul-14 4:33am    
The mouse itself isn't a huge problem, but it can cause one when the user does things you don't expect: if he holds a key down and moves the focus away from your control, you won't get the matching KeyUp event so when he comes back you can start off ignoring his typing - which frustrates and annoys users a lot! Provided you are aware of this and code to allow for it, there isn't a problem, but otherwise it's the kind of thing that generates some really nasty bug reports that are pretty much impossible to track down! :laugh:
Cenkay Vergili 18-Jul-14 5:02am    
Well I am just 17 and I am so unexperienced . I can't do everything I think .
When I find a good solution/way I can not always use it. Because of my knowledge.
So I am doing my best ^^ .
OriginalGriff 18-Jul-14 5:17am    
That's cool - it wasn't a criticism, just a warning that you have to be aware of "unintentional side effects"! :laugh:

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