Knowledge Base

ShellBrowser .NET Components



Question / Problem

How do I make a context menu work with the ShellListView or ShellTreeView?

Answer / Solution

Assign the ContextMenuStrip property. It is converted to a ContextMenu instance which is a wrapper of the Windows Shell-API and therefore can be merged with the menu provided by the operating system, including the extensions of third-party applications.
The OnOpening and OnClosing events are mapped to the Popup/Collapse events respectively. Other events provided by ContextMenuStrip are not triggered. A menuitem of course provides the OnClick event.

Furthermore, a property "BackgroundContextMenu" can be assigned for the ListViews of ShellBrowser. It's displayed if the user clicks the right mouse button without having an item selected. A real ToolStripMenu instance can be used here with all events that it supports. It is however recommended to set the RenderMode property to "System" to keep the look & feel consistent with the shell context menu.

Sample code can be found in the JamExplorer example.