Remove/Delete row from DataGridView

How I can remove/delete row or set of rows from DataGridView ?
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.

SAMIR BHOGAYTATeam LeadCommented:

Write code in rowdeleting event of a gridview. or use this code.
You can use the .Rows.Remove either in the DataGridView or the DataTable which is being used as the datasource.
ty-exexch-koAuthor Commented:
I want to know how delete row of DataGridView in Vb.NET
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

That's what I said above.
Anurag AgarwalCommented:
try this

Use the Rows collection's Remove or RemoveAt method. The following code checks to see if the current row is new because you cannot delete a new row. It then removes the current row.  
Private Sub btnDelete_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnDelete.Click
    If Not DataGridView1.CurrentRow.IsNewRow Then
    End If
End Sub

You select the entire row by clicking the header on the right of the DataGridView.
Then  you can use the following code to remove a row(s) from the control. You can select more than one row for deletion at a time.

// remove all rows selected  
 For Each dr As DataGridViewRow In DataGridView1.SelectedRows
      If DataGridView1.Rows.Count > 1 Then
      End If

Shahan AyyubSenior Software EngineerCommented:

To delete all rows:

To delete Selected ROW:

To delete Selected ROWS:
        For i As Integer = 0 To DataGridView1.SelectedRows.Count - 1

ty-exexch-koAuthor Commented:
Thanks for all answers

I need for example to delete the 2nd row from Datagridview without select the row ?
Anurag AgarwalCommented:
hi ty-exexch-ko,
'Remove the 2nd row down as


'row counting starts at zero.
you can write this on click of button or any function call, just give the index number(less than one as row count starts from 0) of the row you want to delete .

Happy new year!!

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
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
.NET Programming

From novice to tech pro — start learning today.