5

Context menus

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?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574

1 Answers1

7

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;
    }
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • 2
    Is there some alternative solution? I need to assign the menu to the `ContextMenuStrip` property of a `NotifyIcon`, and `ContextMenu`s aren't supported. – Ry- Feb 11 '12 at 02:20
  • 1
    @minitech simply set `notifyIcon.ContextMenu = contextMenu1` as well – lshepstone Mar 25 '13 at 18:11
  • @lawrance.shepstone: Oh, thanks. I must have missed the part about the designer last time :D – Ry- Mar 26 '13 at 15:50
  • Will it work with dynamically added standard `ToolStripMenuItem` controls? – Glitch Sep 06 '15 at 11:58