Solved

DataGridView - programatically hit the F2 key

Posted on 2006-07-09
6
1,139 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
Industry Leaders: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Help with exporting to excel 4 44
Change Locale for Crystal Reports Dynamically in VB.Net 2010 Winforms. 3 30
VB.net Filesystem watcher not working 5 35
vb.net sendkey 4 18
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

763 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