DataSourceView.CanDelete 属性

定义

获取一个值,该值指示与当前 DataSourceControl 对象关联的 DataSourceView 对象是否支持 ExecuteDelete(IDictionary, IDictionary) 操作。

public:
 virtual property bool CanDelete { bool get(); };
public virtual bool CanDelete { get; }
member this.CanDelete : bool
Public Overridable ReadOnly Property CanDelete As Boolean

属性值

如果支持该操作,则为 true;否则为 false。 基类实现返回 false

示例

下面的代码示例演示如何在扩展 DataSourceView 类的类中重写 CanDelete 属性和 ExecuteDelete 方法。 此代码示例是为 DataSourceView 类提供的一个更大示例的一部分。

// The CsvDataSourceView does not currently
// permit deletion. You can modify or extend
// this sample to do so.
public override bool CanDelete {
    get {
        return false;
    }
}
protected override int ExecuteDelete(IDictionary keys, IDictionary values)
{
    throw new NotSupportedException();
}
' The CsvDataSourceView does not currently
' permit deletion. You can modify or extend
' this sample to do so.
Public Overrides ReadOnly Property CanDelete() As Boolean
   Get
      Return False
   End Get
End Property

Protected Overrides Function ExecuteDelete(keys As IDictionary, values As IDictionary) As Integer
   Throw New NotSupportedException()
End Function 'ExecuteDelete

注解

属性 CanDelete 不仅反映数据源控件的功能,还反映当前是否适合执行操作。 例如,即使数据源视图一般支持 ExecuteDelete 操作,如果未设置所需的属性或其他一些数据,该 CanDelete 属性也会 false返回 ,因为删除操作会失败。

适用于

另请参阅