Reputation: 827
I want to have different popup menu on Items and SubItems and NO Popup menu on empty area of a TTreeView is that possible ?
I want something like the pictures bellow
Upvotes: 2
Views: 1772
Reputation: 598134
There are two ways you can do that.
Create 2 separate TPopupMenu
objects with the desired menu items, do not assign either one of them to the TreeView's PopupMenu
property, and then use the TreeView's OnContextMenu
event to call the Popup()
method of whichever TPopupMenu
you need based on which node the user is clicking on.
Create 1 TPopupMenu
object and put both menu items in it, and assign it to the TreeView's PopupMenu
property, then use the TPopupMenu.OnPopup
event to show/hide the menu items based on which node the user is clicking on.
In either case, you can use the TTreeView.GetNodeAt()
method to determine which node is located at the coordinates of a mouse click, if any.
Upvotes: 3