Skip to content

Edit data

Flexible TreeView allows you not only to display data but also to edit it in place.

To enable data editing, enable the Editable node control property (not supported by all node controls) and click that node control in the treeview (also, see EditStartMode node control property) or press a key defined in the EditHotKey node control property.

When a user starts editing data in the treeview, Flexible TreeView raises the events in this sequence:

  • NodeEditing - when the node edit starts. You can cancel the edit in this event so the edit control won't be shown.
  • NodeEditorAdjust - adjusts the editor location before it is shown.
  • NodeEditorShown - when the node edit has started and an editor control is shown.
  • NodeEditValidate - when the user changes the editor control's value. You can validate that value and cancel changes.
  • NodeEdited - when the node edit is finished.

Note

When you start to edit by mouse click the data shown in the node, Flexible TreeView reacts only to clicks on the node control's body, so if it contains no data, you can't start to edit by mouse. You can tell the node control to fill all available free space, and then you can start to edit by click even on empty space. To do that, enable the FillFreeSpace node control property. On the other hand, using a shortcut, you can start to edit even for a node control with empty content.

EditStartMode#

Modifying the EditStartMode node control property allows you to determine when to start data editing of each editable control and you have the following options:

  • Disabled - does not start editing automatically.
  • Click - starts editing after clicking on a node whatever state it is in (non-selected, selected, focused, hot, or soft-selected).
  • ClickOnSelected - starts editing only after clicking on a selected or a focused node.

Tip

You can delay the edit start by using the EditStartDelay treeview property.

NodeEditorAdjust event#

When starting node editing, Flexible TreeView calculates the appearing editor control location and raises the NodeEditorAdjust treeview event. This event is intended to adjust the editor location manually or, in case you do not like it, fix the editor's calculated location a bit while the changes are applied to the editor by the treeview.

If you need to fix the editor's calculated location, just change the passed EditorLocation event argument, and your changes will be applied to the editor automatically.

Example

void tree_NodeEditorAdjust(FlexibleTreeView treeview, ARMSoft.FlexibleTreeView.Events.Nodes.NodeEditorAdjustEventArgs args)
{
    // shift the editor by two pixels.
    args.EditorLocation.X += 2;
    args.EditorLocation.Y += 2;
}
Private Sub tree_NodeEditorAdjust(treeview As FlexibleTreeView, args As ARMSoft.FlexibleTreeView.Events.Nodes.NodeEditorAdjustEventArgs)
    ' shift the editor by two pixels.
    args.EditorLocation.X += 2
    args.EditorLocation.Y += 2
End Sub

When the editor location should be managed manually, just adjust the editor location by using the passed Editor event argument and set the Handled event argument to true after that to disable any further actions regarding the editor location. When handling this situation, you can use the editor calculated location that is passed in the EditorLocation event argument as shown below.

Example

void tree_NodeEditorAdjust(FlexibleTreeView treeview, ARMSoft.FlexibleTreeView.Events.Nodes.NodeEditorAdjustEventArgs args)
{
    Point pt = args.EditorLocation;
    pt.X += 5;
    args.Editor.Location = pt;

    // the editor location is adjusted and no additional actions are required.
    args.Handled = true; 
}
Private Sub tree_NodeEditorAdjust(treeview As FlexibleTreeView, args As ARMSoft.FlexibleTreeView.Events.Nodes.NodeEditorAdjustEventArgs)
    Dim pt As Point = args.EditorLocation

    pt.X += 5
    args.Editor.Location = pt

    ' the editor location is adjusted and no additional actions are required.
    args.Handled = True
End Sub

Additional API reference#

Properties#

  • NodeControl.Editable - defines whether the node control can edit data it contains.
  • TreeView.EditorShowDelay - delay in milliseconds before showing the edit control.
  • NodeControl.EditStartMode - defines when to start editing.
  • NodeControl.EditHotKey - contains a shortcut for starting to edit.
  • NodeControl.ApplyChangesOnLostFocus - defines whether to save changes when the edit control loses focus.
  • NodeControl.MaxEditorWidth/MinEditorWidth - defines the minimum and maximum edit control size.