Making newly added datagridview row the current row

This is a pretty simple question yet I don't know how to find the answer via google. I add a new row to a datagridview using the statement:

dgv.Rows.Add()

Open in new window


What I need to do is retrieve that new row so I can add data to it but the DGV itself is not editable. I will basically be adding data to it using textboxes and comboboxes. I'm assuming I need to create a new instance of a DataGridViewRow but not sure how to get the newly added row.
BlakeMcKennaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Priya SudharsanProgrammer AnalystCommented:
Here is my own example attached.
AppSam.jpgJust fill the textboxes right above the DataGrid and click Add. Write the code in Add button to take the data from those textboxes and Add it to your DataGrid. Then refresh the DataGridView. You are done.
0
BlakeMcKennaAuthor Commented:
I ended up doing this...

dgv.Rows.Add()

dgv.Rows(dgv.RowCount - 1).Cells(0).Value = ???
.
.
.

Open in new window

0
BlakeMcKennaAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for BlakeMcKenna's comment #a40276618
Assisted answer: 500 points for Priya Sudharsan's comment #a40276599

for the following reason:

It works now!
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Fernando SotoRetiredCommented:
Hi BlakeMcKenna;

You can get the row index of the newly add row by doing this.

Dim rowIndex As Integer = dgv.Rows.Add()

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BlakeMcKennaAuthor Commented:
Ah...that's what I'm looking for Fernando...thank you!
0
Fernando SotoRetiredCommented:
Not a problem Blake, always glad to help.
0
Fernando SotoRetiredCommented:
Hi BlakeMcKenna;

If my solution answered your  question you can close the thread out.

Thanks.
0
BlakeMcKennaAuthor Commented:
Sorry Fernando...I think I had started to delete the question before your answer! Cheers!
0
Fernando SotoRetiredCommented:
Not a problem Blake, glad I was able to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.