DataColumnCollection.RemoveAt 方法

从集合中移除指定索引位置的列。

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

语法

声明
Public Sub RemoveAt ( _
    index As Integer _
)
用法
Dim instance As DataColumnCollection
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
    要移除的列的索引。

异常

异常类型 条件

ArgumentException

该集合在指定的索引位置没有列。

备注

如果通过添加或移除列成功更改集合,则会发生 CollectionChanged 事件。

示例

下面的示例首先使用 Contains 方法来确定集合中是否存在特定的列。如果找到该列,则 CanRemove 方法测试是否可以移除该列。如果可以,则用 RemoveAt 方法移除该列。

Private Sub RemoveColumnAtIndex(thisIndex As Integer)
   ' Get the DataColumnCollection from a DataTable in a DataSet.
   Dim columns As DataColumnCollection = _
       DataSet1.Tables("Orders").Columns

   If columns.CanRemove(columns(thisIndex)) Then 
      columns.RemoveAt(thisIndex)
   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

请参见

参考

DataColumnCollection 类
DataColumnCollection 成员
System.Data 命名空间
IndexOf
Contains
CanRemove