Solved

Programmatically setting the focus on a cell in a datagridview

Posted on 2007-03-26
5
1,292 Views
Last Modified: 2008-01-09
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
Comment
Question by:EXTRHMAN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 4

Expert Comment

by:jtaylor8181
ID: 18794891
Try this:

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

and make sure that the selection mode is cellselect.
0
 
LVL 1

Author Comment

by:EXTRHMAN
ID: 18795368
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
 
LVL 1

Author Comment

by:EXTRHMAN
ID: 18801584
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
 
LVL 1

Accepted Solution

by:
Vee_Mod earned 0 total points
ID: 19118815
Closed, 125 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question