How to display a Windows 7 style context menu?

孤街醉人 提交于 2020-01-01 05:43:10

问题


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;
    }


来源:https://stackoverflow.com/questions/5055433/how-to-display-a-windows-7-style-context-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!