Skip to main content
.NET 6.0+

PropertyEditor.AllowEdit Property

Provides access to a collection of reason/value pairs used to make a PropertyEditor read-only/editable.

Namespace: DevExpress.ExpressApp.Editors

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public BoolList AllowEdit { get; }

Property Value

Type Description
BoolList

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

Remarks

The example below demonstrates how to make a Contact object’s FirstName field read-only.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
// ...
public class FirstNameController : ObjectViewController<DetailView, MainDemo.Module.BusinessObjects.Contact> {
    protected override void OnActivated() {
        PropertyEditor firstNamePropertyEditor = (PropertyEditor)View.FindItem("FirstName");
        firstNamePropertyEditor.AllowEdit["Read-Only"] = false;
    }
}

The AllowEdit is a collection whose elements represent a pair of string and Boolean values. The string value specifies a reason and the Boolean value specifies whether to make the Property Editor editable for this reason. A Property Editor is considered read-only if at least one of the AllowEdit collection elements contains a false value.

To determine whether a Property Editor is currently read-only, use the AllowEdit property in a conditional expression. Alternatively, use the BoolList.ResultValue property of the object returned by AllowEdit.

PropertyEditor myEditor;
//...
BoolList editableList = myEditor.AllowEdit;
if (editableList) {
    //...
}

To make an editable Property Editor read-only, use the BoolList.SetItemValue method of the BoolList object returned by this property. Pass the reason for making the Property Editor read-only 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 AllowEdit property, to get or set the specified key’s value.

PropertyEditor myEditor;
//...
BoolList editableList = myEditor.AllowEdit;
editableList["myKey"] = false;

To make a read-only Property Editor editable, use the BoolList.RemoveItem method of the BoolList object returned by this property. Pass the key (reason) of the item with the false value. If this is a single item that has the false value, the Property Editor will become editable. Alternatively, you can use the BoolList.SetItemValue method by passing the key, which has false as a value, and true as a new value for it.

PropertyEditor myEditor;
//...
BoolList editableList = myEditor.AllowEdit;
editableList["disablingKey"] = true;

When a Property Editor’s read-only state is changed, the PropertyEditor.AllowEditChanged event is raised.

See Also