Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

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.v20.2.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.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AllowEdit property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also