How to display a Windows 7 style context menu?

2020-06-20 12:52发布

问题:

In my .NET applications, context menus look like the left one.

How can I apply the Windows 7 style on them in order to make them look like the right one?

回答1:

Right-click the tool box, Choose Items. Tick "ContextMenu", the one with Namespace = System.Windows.Forms and Directory = Global Assembly Cache.

This .NET 1.x component is distinct from ContextMenuStrip, it uses native Windows menus. You'll lose some capabilities, I doubt you care. You'll need to write a line of code to assign the menu, the designer only lets you set the ContextMenuStrip property. Add that line to the constructor, like:

    public Form1() {
        InitializeComponent();
        this.ContextMenu = contextMenu1;
    }