FAQ & Knowledge Base

Welcome to our Knowledge Base. Search or browse through the topics below to find answers to your questions.

Categories: ShellBrowser .NET Components | Show all categories

Subclassing the context menu

Question / Problem

How can I extend the background context menu of the ShellListView with additional items, is it possible hide default items?

Answer / Solution

Have a look at the JamExplorer example, here we override the BackgroundContextMenu class and add an additional ToolStripMenuItem in the SetupMenuItem method. To hide a default item, you can simply set its Visibility property, see the API of the BackgroundContextMenu class to get an overview of the defined Properties.


class MyBackgroundContextMenu : BackgroundContextMenu {
   protected override void SetupMenuItems() {
      base.SetupMenuItems();
      Items.Add(new ToolStripMenuItem("My Additional Item"));
            
      //hide a default item:
      this.Actualize.Visible = false;
   }
}
   
public partial class JamExplorerMain : Form {
   public JamExplorerMain() {
      InitializeComponent();
      shellListView1.BackgroundContextMenu =
        new MyBackgroundContextMenu();
   }
   ...
}