Link to home
Start Free TrialLog in
Avatar of BlakeMcKenna
BlakeMcKennaFlag for United States of America

asked on

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.
Avatar of Priya Sudharsan
Priya Sudharsan

Here is my own example attached.
User generated imageJust 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.
Avatar of BlakeMcKenna

ASKER

I ended up doing this...

dgv.Rows.Add()

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

Open in new window

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!
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah...that's what I'm looking for Fernando...thank you!
Not a problem Blake, always glad to help.
Hi BlakeMcKenna;

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

Thanks.
Sorry Fernando...I think I had started to delete the question before your answer! Cheers!
Not a problem Blake, glad I was able to help.