windowsforms-401606-controls-and-libraries-tree-list-visual-elements-node-context-menu.md
If the TreeList.OptionsMenu.EnableNodeMenu option is enabled, the tree list shows a context menu when a user right-clicks a node.
The context menu contains the following predefined commands:
Use the TreeList.OptionsMenu.ShowExpandCollapseItems property to hide these commands.
If the control displays the New Item Row, the context menu also contains the following commands:
Use the TreeList.OptionsMenu.ShowAddNodeItems property to hide/show these items regardless of the New Item Row visibility.
Refer to the following help topic for more information on how to customize this menu: Context Menus.
View Example: Customize Node Context 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);
}
}
}
Imports DevExpress.XtraTreeList.Localization
TreeListLocalizer.Active = New NodeContextMenuLocalizer()
Public Class NodeContextMenuLocalizer
Inherits TreeListLocalizer
Public Overrides ReadOnly Property Language() As String
Get
Return "English"
End Get
End Property
Public Overrides Function GetLocalizedString(ByVal id As TreeListStringId) As String
Select Case 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"
Case Else
Return MyBase.GetLocalizedString(id)
End Select
End Function
End Class
See Also