Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi how do i control key in datageidview editmode.
for example in edit mode on datagridview ,when i press F2 ,show me a MessageBox
thanks
Posted

1 solution

You don't really give much information to go on so the answer is going to be very general. Most grid controls have a cell editor component that you can override. You will need to extend the original editor component to intercept the keydown event where you will check for the additional keys you are interested in and respond with whatever you want it to do (pop a message box, flip the screen, play 'Never gonna give you up... whatever). Don't forget to set the event handled flag so it doesn't get sent through the rest of the UI tree. Just assign your extended cell editor as the editor on the grid and it should work.

Look in the documentation for the grid you are using about creating/overriding default cell editor behavior. That should have what you need for your specific grid. If your grid doesn't allow you to change the default cell editor, then change grids.
 
Share this answer
 

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