EXTRHMAN
asked on
Programmatically setting the focus on a cell in a datagridview
I have a datagridview that users will enterdata into. When the form loads the first cell in the NEWROW of the datagrid should have focus and be ready for data entry (blinking cursor). I am using the following code below to do this but it is not working.
datagridview1.focus
datagridview1.currentcell = datagridview1.Rows(0).Cell s(0)
datagridview1.beginedit(tr ue)
Using this I don't get a blinking cursor and I can't just start typing. I have also tried inserting a row with dumby data in the first cell to see if that helps and it does not. I also tried removing the datagridview1.focus line but that does not help either.
datagridview1.focus
datagridview1.currentcell = datagridview1.Rows(0).Cell
datagridview1.beginedit(tr
Using this I don't get a blinking cursor and I can't just start typing. I have also tried inserting a row with dumby data in the first cell to see if that helps and it does not. I also tried removing the datagridview1.focus line but that does not help either.
ASKER
jtaylor8181 - Thanks for responding
I tried your suggestion and got the same results. I had not thought of changing the selection method.
If I hit the enter key I can then start typing. If that helps at all.
I tried your suggestion and got the same results. I had not thought of changing the selection method.
If I hit the enter key I can then start typing. If that helps at all.
ASKER
I found a solution that works for this project, but would still like to here anyone elses ideas.
I used sendkeys.send(vbcrlf) on the form_load event
I will leave this question open for a bit longer before I ask for a refund of points. If someone can give me a better solution then I will reward the points to them.
I used sendkeys.send(vbcrlf) on the form_load event
I will leave this question open for a bit longer before I ask for a refund of points. If someone can give me a better solution then I will reward the points to them.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
datagridview1.currentcell = datagridview1.Item(0, 0)
and make sure that the selection mode is cellselect.