Subclassing the context menu
Frage / Problem
How can I extend the background context menu of the ShellListView with additional items, is it possible hide default items?
Antwort / Lösung
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();
}
...
}