[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1307
  • Last Modified:

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).Cells(0)
datagridview1.beginedit(true)

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.
0
EXTRHMAN
Asked:
EXTRHMAN
  • 2
1 Solution
 
jtaylor8181Commented:
Try this:

datagridview1.currentcell = datagridview1.Item(0, 0)

and make sure that the selection mode is cellselect.
0
 
EXTRHMANAuthor Commented:
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.
0
 
EXTRHMANAuthor Commented:
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.
0
 
Vee_ModCommented:
Closed, 125 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now