This documentation is archived and is not being maintained.

DataRowCollection.Remove Method

Removes the specified DataRow from the collection.

[Visual Basic]
Public Sub Remove( _
   ByVal row As DataRow _
public void Remove(
 DataRow row
public: void Remove(
 DataRow* row
public function Remove(
   row : DataRow


The DataRow to remove.


When a row is removed, all data in that row is lost. You can also call the Delete method of the DataRow class to simply mark a row for removal. Calling Remove is the same as calling Delete and then calling AcceptChanges.

You can also use the Clear method to remove all members of the collection at once.


[Visual Basic] The following example uses the Remove method to delete a found row in a DataRowCollection object. The example first uses the Contains method to determine if the rows collection contains a row. If so, the Find method is used to find the specific row, and the Remove method is then used to remove the row.

[Visual Basic] 
Private Sub RemoveFoundRow(ByVal myTable As DataTable)
    Dim myDataRowCollection As DataRowCollection
    Dim foundRow As DataRow
    myDataRowCollection = myTable.Rows
    ' Test to see if the collection contains the value.
    If myDataRowCollection.Contains(TextBox1.Text) Then
       foundRow = myDataRowCollection.Find(TextBox1.Text)
       Console.WriteLine("Row Deleted")
       Console.WriteLine("No such row found.")
    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

DataRowCollection Class | DataRowCollection Members | System.Data Namespace | Add | Clear | Contains | Find