|
|
Title | Remove the current row from a DataGridView control in Visual Basic 2005 |
Description | This example shows how to remove the current row from a DataGridView control in Visual Basic 2005. |
Keywords | DataGridView, remove row, delete row, Visual Basic 2005, VB 2005 |
Categories | Controls, VB.NET |
|
|
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
DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
End If
End Sub
|
|
|
|
|
|