Solved

DataGridView - programatically hit the F2 key

Posted on 2006-07-09
6
1,107 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
  • 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 142

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 142

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now