DataRowView.Delete 方法

定义

删除行。

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

示例

以下示例对行使用 Delete 方法。

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

注解

在对行所属的 调用DataTable之前AcceptChanges,不会永久删除该行。

注意

DataRowView从基础表中删除 时, DataRow 可能无效。 DataRowView当 变得无效时,访问与 DataRowView关联的值的操作(如 Delete)将引发异常。

适用于

另请参阅