Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Making newly added datagridview  row the current row

Posted on 2014-08-21
9
Medium Priority
?
227 Views
Last Modified: 2014-08-21
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.
0
Comment
Question by:BlakeMcKenna
  • 4
  • 4
9 Comments
 
LVL 2

Expert Comment

by:Priya Sudharsan
ID: 40276599
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
 

Author Comment

by:BlakeMcKenna
ID: 40276618
I ended up doing this...

dgv.Rows.Add()

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

Open in new window

0
 

Author Comment

by:BlakeMcKenna
ID: 40277688
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
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 64

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 40277003
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
 

Author Comment

by:BlakeMcKenna
ID: 40277049
Ah...that's what I'm looking for Fernando...thank you!
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40277057
Not a problem Blake, always glad to help.
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40277685
Hi BlakeMcKenna;

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

Thanks.
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 40277689
Sorry Fernando...I think I had started to delete the question before your answer! Cheers!
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40277742
Not a problem Blake, glad I was able to help.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

580 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