DataRowCollection.RemoveAt(Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從集合的指定索引處移除資料列。
public:
void RemoveAt(int index);
public void RemoveAt (int index);
member this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)
參數
- index
- Int32
要移除之資料列的索引。
範例
下列範例會藉由呼叫 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
備註
拿掉資料列時,該數據列中的所有數據都會遺失。 您也可以呼叫 Delete 類別的 DataRow 方法,只標記要移除的數據列。 呼叫 RemoveAt
與呼叫 Delete 相同,然後呼叫 AcceptChanges。
您可以使用 Clear 方法一次移除集合的所有成員。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應