Search code examples
vb.netwinformsvisual-studiodesigner

Visual Studio 2015 - Context menu system style


When I create a ContextMenuStrip in a Windows Forms Application and set the RenderMode to System, it looks like this:

enter image description here

However, the Windows 10 system context menu looks like this:

enter image description here

How do I make the WinForms Menu look like the actual system one?


Solution

  • I think you are looking for a ContextMenu, not a ContextMenuStrip.
    Some time ago the ContextMenu, which uses native Windows menus got replaced by the ContextMenuStrip (that also offers additional functionality).
    Straight from the docs:

    ContextMenuStrip replaces ContextMenu [...]

    I don't have any VS near me at the moment, but I remember the designer will only let you assign a ContextMenuStrip. However, you can just set it by code:

    this.ContextMenu = contextMenu; //preferably in the constructor of the form
    

    If I remember this right you have to import the ContextMenu into the toolbox first. Right click the Toolbox, Choose Toolbox Items and look for the ContextMenu with the namespace System.Windows.Forms in the GAC (global assembly cache).