Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Disable Cell Editors and Nodes

  • 2 minutes to read

If a cell is disabled, the user cannot edit and select its value.

#Disable All Cells

Set the TreeList’s OptionsBehavior.Editable property to false to disable all cells.

treeList1.OptionsBehavior.Editable = false;

#Disable Cells in a Column

Set a column’s OptionsColumn.AllowEdit property to false to disable its cells.

treeList1.Columns["Region"].OptionsColumn.AllowEdit = false;

Enable a column’s OptionsColumn.ReadOnly setting to make its cells read-only (the OptionsColumn.AllowEdit property must be set to true). The user can invoke the cell’s editor to copy its value, but cannot edit that value.

treeList1.OptionsBehavior.Editable = true;
treeList1.Columns["Region"].OptionsColumn.AllowEdit = true;
treeList1.Columns["Region"].OptionsColumn.ReadOnly = true;

#Disable Specific Cells and Nodes Based on a Condition

Use one of the following options to disable specific cells or nodes based on a condition:

  • Handle the ShowingEditor event and set the e.Cancel parameter to true to disable the processed cell based on a specific condition.

    The following example handles the ShowingEditor event to disable cells in the focused row if the value in the Region column is “Germany”:

    private void treeList1_ShowingEditor(object sender, CancelEventArgs e) {
        string cellValue = treeList1.GetRowCellValue(treeList1.FocusedNode, "Region").ToString();
        e.Cancel = cellValue == "Germany";
    }
    

    The following example prevents users from editing cells in the “Region” column in child nodes (the example makes cells read-only):

    private void treeList1_ShownEditor(object sender, EventArgs e) {
        treeList1.ActiveEditor.Properties.ReadOnly = treeList1.FocusedColumn.FieldName == "Region" && treeList1.FocusedNode.Level > 0;
    }
    
  • Use the Disabled Cell Behavior to disable cells in nodes that meet a specific condition. Disabled cells are grayed-out and cannot be edited.