Click here to Skip to main content
15,908,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can i add new row in datagridview in between existing rows.datagridview does not have any datasource.and want to add new row at specificposition at run time
Posted

You can use DataGridViewRowCollection.Insert Method[^] for this.

However, I would consider defining a datasource for the datagridview and possibly use sorting for the data.
 
Share this answer
 
VB
Private Sub InsertRowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertRowToolStripMenuItem.Click

    For Each row as DatagridviewRow in DataGridView1.SelectedRows
        DataGridView1.Rows.Insert(row.index, 1)
    Next

End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900