DataRowCollection.Remove 方法

从集合中移除指定的 DataRow

**命名空间:**System.Data
**程序集:**System.Data(在 system.data.dll 中)

语法

声明
Public Sub Remove ( _
    row As DataRow _
)
用法
Dim instance As DataRowCollection
Dim row As DataRow

instance.Remove(row)
public void Remove (
    DataRow row
)
public:
void Remove (
    DataRow^ row
)
public void Remove (
    DataRow row
)
public function Remove (
    row : DataRow
)

参数

备注

当移除行时,该行中的所有数据都将丢失。还可以调用 DataRow 类的 Delete 方法来标记某行以供移除。调用 Remove 等同于先调用 Delete 再调用 AcceptChanges

还可使用 Clear 方法一次移除集合中的所有成员。

示例

下面的示例使用 Remove 方法删除在 DataRowCollection 对象中找到的行。该示例首先使用 Contains 方法确定行集合中是否包含某一行。如果包含,则使用 Find 方法查找特定行,然后使用 Remove 方法移除该行。

Private Sub RemoveFoundRow(ByVal table As DataTable)
    Dim rowCollection As DataRowCollection = table.Rows

    ' Test to see if the collection contains the value.
    If rowCollection.Contains(TextBox1.Text) Then
        Dim foundRow As DataRow = rowCollection.Find(TextBox1.Text)
        rowCollection.Remove(foundRow)
        Console.WriteLine("Row Deleted")
    Else
        Console.WriteLine("No such row found.")
    End If
 End Sub

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

DataRowCollection 类
DataRowCollection 成员
System.Data 命名空间
Add
Clear
Contains
Find