Skip to main content

TcxCustomTreeView.IsEditing Method

Indicates whether the user is currently editing a node caption.

Declaration

function IsEditing: Boolean;

Returns

Type
Boolean

Remarks

Use the IsEditing method to determine whether the user is currently editing a node caption. If so, the method returns True. Otherwise, False. Note that node editing is only allowed if the ReadOnly property of the tree view is set to False.

The sample code below shows how to toggle the editing mode for the currently selected node in response to pressing specific keys. The F2 key toggles the editing mode for the currently selected node. The ESC key stops node caption editing without saving changes made. The OnKeyDown event of the tree view control is handled to respond to key press events.

procedure TForm1.cxTreeView1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var SelectedNode: TTreeNode;
begin
  SelectedNode := cxTreeView1.Selected;
  if SelectedNode = nil then Exit;
  if Key = VK_F2 then
  begin
    if cxTreeView1.IsEditing then
      TreeView_EndEditLabelNow(SelectedNode.Handle, False)
    else
      TreeView_EditLabel(SelectedNode.Handle, SelectedNode.ItemId);
  end;
  if (Key = VK_ESCAPE) and cxTreeView1.IsEditing then
    TreeView_EndEditLabelNow(SelectedNode.Handle, True);
end;

Please refer to the Tree-View Label Editing, TreeView_EditLabel and TreeView_EndEditLabelNow topics of the Windows SDK help system for details on editing node captions at runtime.

See Also