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.

备注

DataRowViewDataRow 从基础表中删除时,可能无效。A 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.

适用于

另请参阅