Skip to main content

Deleting Nodes

To delete nodes at runtime, set the OptionsData.Deleting property to True and press the Ctrl+Del key combination to delete the selected records.

If the OptionsSelection.MultiSelect property is set to True, several nodes can be selected. Otherwise, only one record can be selected (the one with focus).

To delete records programmatically, use the TreeList control’s DeleteSelection method. This method deletes selected and focused nodes and does not require any parameters, as shown in the following code:

try
    cxDBTreeList1.DeleteSelection;
  except
    on E: Exception do
      ShowMessage('Cannot delete selected nodes due to the exception: ' + E.Message);
  end;

An exception may occur if records cannot be deleted. This can be caused, for instance, if the deletion violates integrity rules. If you are working with an unbound TreeList control, there is no need to handle the exception for the DeleteSelection method, since it should not generate any exception.

See Also