?
Solved

VB.net Add DataGridView row after the last

Posted on 2014-08-16
6
Medium Priority
?
1,446 Views
Last Modified: 2014-08-20
Hi
I a trying to add a DataGridView row after the last ro using the following code but it is adding it at the beginning before the first row

       Dim sTextDragged As String = DirectCast(e.Data.GetData(GetType(System.String)), System.String)
                Dim oNewRow As New DataGridViewRow
                oNewRow.CreateCells(Me.DGV_Joins)
                oNewRow.Cells(0).Value = "Joined"
                oNewRow.Cells(1).Value = sTextDragged
                oNewRow.Cells(2).Value = "<none>"
                oNewRow.Cells(3).Value = "Joined"
                Me.DGV_Joins.Rows.Add(oNewRow) '
0
Comment
Question by:Murray Brown
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40265424
Is this a data-bound grid, or an unbound grid?
0
 

Author Comment

by:Murray Brown
ID: 40265780
It is an unbound GridView
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40266160
With an Unbound DataGridView, I prefer to use the VirtualMode, and then you can control the operations.

Here is a description:

Walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control
http://msdn.microsoft.com/en-us/library/15a31akc(v=vs.110).aspx
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Murray Brown
ID: 40271854
Thanks Bob but I still just need a way to add a row at the end rather than the beginning
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 40274196
In virtual mode, that would be RowCount + 1.  For non-virtual mode, try:

dataGridView1.Rows.Insert(dataGridView1.Rows.Count - 1, row)
0
 

Author Closing Comment

by:Murray Brown
ID: 40275496
Thanks very much
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
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. …
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

809 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