简体   繁体   中英

Visual Studio add-in : Context sensitive context menu

I've built a Visual Studio add-in that is specific to class properties and fields. I want to only have my menu show when the selected items are one of the supported element types (property, variable). Any ideas how to configure the this, OR, how I can attach to the context menu OnShow (or what ever event it is) so I can determine if I should show the menu or not.

If your add-in implements IDTCommandTarget then you can create a command and attach it to your context menu item. When the menu item is accessed it will call the QueryStatus() method which you can then determine if you want to show/hide menu items. Have a look at http://www.mztools.com/articles/2004/MZ2004003.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM