Back to Devexpress

Disable Cell Editors and Nodes

windowsforms-404826-controls-and-libraries-tree-list-feature-center-data-editing-disable-cell-editors.md

latest2.2 KB
Original Source

Disable Cell Editors and Nodes

  • Feb 19, 2024
  • 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.

csharp
treeList1.OptionsBehavior.Editable = false;
vb
treeList1.OptionsBehavior.Editable = False

Disable Cells in a Column

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

csharp
treeList1.Columns["Region"].OptionsColumn.AllowEdit = false;
vb
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.

csharp
treeList1.OptionsBehavior.Editable = true;
treeList1.Columns["Region"].OptionsColumn.AllowEdit = true;
treeList1.Columns["Region"].OptionsColumn.ReadOnly = true;
vb
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.

  • Use the Disabled Cell Behavior to disable cells in nodes that meet a specific condition. Disabled cells are grayed-out and cannot be edited.