Link to home
Start Free TrialLog in
Avatar of David L. Hansen
David L. HansenFlag for United States of America

asked on

How can I cause a DataGridView Cell to begin edit mode when a user hits a numeric key?

If a user has a row selected I don't want them to have to double click to edit (there is only one column that will ever need to be edited anyway).  I want them to simply begin typing and have that certain cell (always the 5th column) in the current row to begin edit mode.  That way they can just use the keyboard and move from row to row editing this one column of data without every using the mouse.  Again, the other columns will never need to be edited, just this one.
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Can you show the code you have ? Normally you don't need to double cick to start editing.
Avatar of David L. Hansen

ASKER

I have no code attempts.  I'm not sure where to begin.  All I have right now is the datagridview set to fullrowselect mode.  
Now, with that mode being set, the user only highlights a row (when using a single click) instead of editing...no problem so far, this behavior is what I want.  Currently then, the user can only enter edit mode on a single cell by double-clicking on it.  What I want to do is give the user an additional, alternative way of editing cells, in a quick, keyboard approach (ie. they begin typing when a row is highlighted and it automatically begins to edit the cell in column 5 of the current row).
Let me see if I understood ...
You want to keep the selection to full row mode but when the user starts to type it writes on column 5. Is that it ?
Yes, that's exactly what I want.
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think we are on the right track...I like your solution; it doesn't do anything for me though.  I've incorporated the code and it runs without error.  However, when I select a row and begin typing, nothing happens...no errors no changes...nothing.  The row remains selected though.  Are we missing something?
Have you add this code after fill the datagridview ?
Notice that I have used the column number 4 for this snippet and you have to choose the right one.
I added the code, changed the column number (with a zero based index the column I need is 5), updated the datagridview name and ran the program in debug mode.  The grid fills with data, I highlight a row, then begin typing...nothing happens.  Does it work for you?
>> Does it work for you?
Sure :)  I always test the vode before post here.
Do you use some other code ? Can you show what you have so far ?