Solved

DataGridView - programatically hit the F2 key

Posted on 2006-07-09
6
1,154 Views
Last Modified: 2008-02-01
In the DataGridView my code is adding a new row, after I do this I would like to go ahead and place the cursor inside the first cell so that the user can start editing its value. How can I do this?

(I want to accomplish the same effect as if the user clicked into the cell or hit the F2 key to begin editing it). I'm trying to save the user from having to take this step.

Also, when a user begins typing a new blank row is autogenerated at the bottom. I want to make sure that this new row appears (otherwise it causes problems for my program).

-Joseph
0
Comment
Question by:brokeMyLegBiking
[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
  • 3
  • 2
6 Comments
 
LVL 4

Author Comment

by:brokeMyLegBiking
ID: 17069117
I figured out how to programatically beginEdit on a cell:

            dataGridView1.CurrentCell = dataGridView1.Rows(dataGridView1.Rows.Count - 1).Cells(0);
            dataGridView1.BeginEdit(false);

Now I just have to solve the second part of my question.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17069123
0
 
LVL 4

Author Comment

by:brokeMyLegBiking
ID: 17069151
That was interesting, but that doesn't qute solve the 2nd issue.

Perhpas if I programmatically send a key to the cell after I put it in edit mode? Is there an easy way to programmatically press a key so that the new row appears? Or is there a better way to make that pesky new row appear?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17069221
does this help?

void Grid_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
   Grid.FirstDisplayedCell = Grid.Rows[e.RowIndex].Cells[0];
}
0
 
LVL 2

Expert Comment

by:TheUnkind
ID: 17077903
try this one

Datagridview1.AllowUserToAddRows = True
0
 
LVL 4

Author Comment

by:brokeMyLegBiking
ID: 17077926
I solved the issue, by just setting the allowusertoAddRows to false and adding a button. That takes the uncertainty out of it.

-Joseph
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

636 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