DataRowCollection.RemoveAt 方法

从集合中移除指定索引处的行。

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

语法

声明
Public Sub RemoveAt ( _
    index As Integer _
)
用法
Dim instance As DataRowCollection
Dim index As Integer

instance.RemoveAt(index)
public void RemoveAt (
    int index
)
public:
void RemoveAt (
    int index
)
public void RemoveAt (
    int index
)
public function RemoveAt (
    index : int
)

参数

  • index
    要移除的行的索引。

备注

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

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

示例

下面的示例通过调用 RemoveAt 方法移除 DataRowCollection 中的最后一行。

 Private Sub RemoveRowByIndex()
    Dim table As DataTable = CType(DataGrid1.DataSource, DataTable)
    Dim rowCollection As DataRowCollection = table.Rows
    If rowCollection.Count = 0 Then 
        Exit Sub
    End If
    rowCollection.RemoveAt(rowCollection.Count - 1)
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 命名空间
Clear
Add