Delete Method

DataView.Delete Method

Deletes a row at the specified index.

[Visual Basic]
Public Sub Delete( _
   ByVal index As Integer _
public void Delete(
 int index
public: void Delete(
 int index
public function Delete(
   index : int


The index of the row to delete.


After deleting a DataRow, its state changes to DataViewRowState.Deleted. You can roll back the deletion by calling RejectChanges on the DataTable.


[Visual Basic] The following example uses the Delete method to delete a row.

[Visual Basic] 
Private Sub DeleteRow(dv As DataView, val As String)
   ' Find the given value in the DataView and delete the row.
   Dim i As Integer
   i = dv.Find(val)
   If i = -1 Then
      ' The value wasn't found
      MessageBox.Show("Value not found in primary key column")
      Exit Sub
   End If
End Sub

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataView Class | DataView Members | System.Data Namespace | DataViewRowState | Find

© 2015 Microsoft