Skip to main content
.NET 8.0+

View.AllowDelete Property

Provides access to a collection of reason/value pairs used to allow or prohibit deletion of objects via a View.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public BoolList AllowDelete { get; }

Property Value

Type Description
BoolList

A BoolList object that represents a collection of key/value elements.

Remarks

There can be various reasons to allow or prohibit deletion of objects via a View. So, a View has the AllowDelete collection, whose elements represent a pair of string and Boolean values. The string value specifies a reason and the Boolean value specifies whether to allow deletion of objects. Objects cannot be deleted if at least one of the AllowDelete collection elements contains a false value.

When deletion of objects is prohibited, the Delete Action is not available. To determine whether object deletion is allowed for a View, use the AllowDelete property in a conditional expression. Alternatively, use the BoolList.ResultValue property of the object returned by AllowDelete.

View myView;
//...
BoolList deletableList = myView.AllowDelete;
if (deletableList) {
    //...
}

To prohibit deletion of objects, use the BoolList.SetItemValue method of the BoolList object returned by this property. Pass the prohibition reason as the first parameter, and false or a Boolean expression as the second parameter. Alternatively, you can use the [key] operator of the BoolList object returned by the AllowDelete property, to get or set the specified key’s value.

View myView;
//...
BoolList deletableList = myView.AllowDelete;
deletableList["myKey"] = false;

To allow objects to be deleted, use the BoolList.RemoveItem method of the BoolList object returned by this property. Pass the key (reason) of the item with the false value. Call this method as many times as there are items with the false value. Alternatively, you can call the BoolList.SetItemValue method by passing the key, which has false as a value, and true as a new value for it.

View myView;
//...
BoolList deletableList = myView.AllowDelete;
deletableList["disablingKey"] = true;
public class MyController : ViewController {
   private void UpdateViewStateEventHandler(object sender, EventArgs e) {
      View..SetItemValue(
          "CurrentUser", SecuritySystem.CurrentUser.FirstName == "Sam");
   }
   protected override void OnActivated() {
      base.OnActivated();
      View.CurrentObjectChanged += UpdateViewStateEventHandler;
   }
}

When a View’s AllowDelete state is changed, the View.AllowDeleteChanged event is raised.

See Also