How can I create a context menu for a Delphi component?

contextmenu, delphi

Solution

Place a TPopupMenu onto your form and design your menu with it. Then select the component the popupmenu is meant for (DbGrid, TreeView, ...) and set it's PopupMenu property to the PopupMenu you just designed.

You can have different PopupMenus for different components.

Problem

I want to create a context menu for Delphi components like `TDBGrid`, `TTreeView` or similar. How can I do that?

Original source