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