All docs
V20.1
20.2 (EAP/Beta)
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

TreeListOptionsMenu.ShowExpandCollapseItems Property

Gets or sets whether to show the expand/collapse commands in the context menu invoked with a right-click on a node.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

[DefaultValue(true)]
[XtraSerializableProperty]
public virtual bool ShowExpandCollapseItems { get; set; }
<DefaultValue(True)>
<XtraSerializableProperty>
Public Overridable Property ShowExpandCollapseItems As Boolean

Property Value

Type Default Description
Boolean

true

true, to show the expand/collapse commands in the context menu invoked with a right-click on a node; otherwise, false.

Property Paths

You can access this nested property as listed below:

Library Object Type Path to ShowExpandCollapseItems
WinForms Controls GanttControl
.OptionsMenu.ShowExpandCollapseItems
ResourcesTree
.OptionsMenu.ShowExpandCollapseItems
TreeList
.OptionsMenu.ShowExpandCollapseItems
Reporting XRDesignFieldList
.OptionsMenu.ShowExpandCollapseItems
XRDesignFieldList
.OptionsMenu.ShowExpandCollapseItems
XRDesignReportExplorer
.OptionsMenu.ShowExpandCollapseItems
XRDesignReportExplorer
.OptionsMenu.ShowExpandCollapseItems

Remarks

If the TreeList.OptionsMenu.EnableNodeMenu option is enabled, the tree list shows a context menu when a user right-clicks a node.

Predefined Commands

The context menu contains the following predefined commands:

  • Collapse (Expand) — collapses (expands) the clicked node. This command is only shown when the node has children.
  • Full Collapse — collapses all nodes.
  • Full Expand — expands all nodes.

To hide these commands, use the TreeList.OptionsMenu.ShowExpandCollapseItems option.

If the control displays the New Item Row, the context menu also contains the following commands:

  • Add Node — creates a new node at the same level as the focused node.
  • Add Child Node — creates a new child node for the focused node.

To hide/show these commands regardless of whether the New Item Row is displayed, use the TreeList.OptionsMenu.ShowAddNodeItems option.

Localize the Menu

The TreeListLocalizer allows you to localize the command captions. Use the following fields to identify a command:

  • MenuNodeCollapse — the Collapse command.
  • MenuNodeExpand — the Expand command.
  • MenuNodeExpandAll — the Full Expand command.
  • MenuNodeCollapseAll — the Full Collapse command.
  • MenuNodeAddNode — the Add Node command.
  • MenuNodeAddChildNode — the Add Child Node command.
using DevExpress.XtraTreeList.Localization;

TreeListLocalizer.Active = new NodeContextMenuLocalizer();

public class NodeContextMenuLocalizer : TreeListLocalizer {
    public override string Language { get { return "English"; } }
    public override string GetLocalizedString(TreeListStringId id) {
        switch (id) {
            case TreeListStringId.MenuNodeCollapse: return "Collapse this node";
            case TreeListStringId.MenuNodeExpand: return "Expand this node";
            case TreeListStringId.MenuNodeExpandAll: return "Expand all nodes";
            case TreeListStringId.MenuNodeCollapseAll: return "Collapse all nodes";
            default: return base.GetLocalizedString(id);
        }
    }
}

Populate the Menu

You can handle the TreeList.PopupMenuShowing event to populate the menu with custom items.

using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Menu;

treeList1.PopupMenuShowing += OnPopupMenuShowing;

void OnPopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
    if (e.Menu is DevExpress.XtraTreeList.Menu.TreeListNodeMenu) {
        AddItem(e.Menu, NodeMenuItemID.Indent, treeList1.CanIndentNodes(treeList1.Selection));
        AddItem(e.Menu, NodeMenuItemID.Outdent, treeList1.CanOutdentNodes(treeList1.Selection));
        e.Allow = true;
    }
}
NOTE

Run the XtraTreeList demo and click Open Solution to see the complete example.

See Also