DataColumnCollection.RemoveAt(Int32) 方法

定義

從集合移除在指定索引處的資料行。

public:
 void RemoveAt(int index);
public void RemoveAt (int index);
member this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)

參數

index
Int32

要移除的資料行索引。

例外狀況

集合的指定索引處不具有資料行。

範例

下列範例會先使用 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

備註

如果加入或移除數據行成功變更集合,就會 CollectionChanged 發生此事件。

適用於

另請參閱