DataRowView.Delete 方法

定義

刪除資料列。Deletes a row.

public:
 void Delete();
public void Delete ();
member this.Delete : unit -> unit
Public Sub Delete ()

範例

下列範例會在資料 Delete 列上使用方法。The following example uses the Delete method on a row.

private void DeleteRow()
{
    DataRowView row;
    DataView view = (DataView) dataGrid1.DataSource;
    row = view[dataGrid1.CurrentCell.RowNumber];
    row.Delete();
}
Private Sub DeleteRow()
     Dim row As DataRowView
     Dim view As DataView = CType(dataGrid1.DataSource, DataView)
     row = view(dataGrid1.CurrentCell.RowNumber)
     row.Delete()
End Sub

備註

在對資料 AcceptChanges 列所屬的上叫用時,才會永久刪除資料列 DataTableThe row is not permanently deleted until AcceptChanges is invoked on the DataTable that the row belongs to.

注意

DataRowView從基礎資料表刪除時,可能會無效 DataRowA DataRowView may be invalid when a DataRow is deleted from the underlying table. DataRowView 變成無效時,存取與相關聯之值的作業( DataRowView 例如 Delete )會擲回例外狀況。When the DataRowView becomes invalid, operations that access values associated with DataRowView, such as Delete, throw an exception.

適用於

另請參閱