简体   繁体   中英

Dynamic multi-level menu in Visual Studio

I am currently using the DynamicItemStart feature to create a list of menu items dynamically and it works fine for normal button items. Is there a way to also dynamically create a list of sub-menus that will then contain the actual command buttons? I want to achieve a structure like this:

File
  My Root Item 
    Group 1 (dynamic)
      Item 1.1 (dynamic)
      Item 1.2 (dynamic)
      Item 1.3 (dynamic)
    Group 2 (dynamic)
      Item 2.1 (dynamic)
    Group 3 (dynamic)
      Item 3.1 (dynamic)
      Item 3.2 (dynamic)

Is this even possible?

You can declare maximum number of groups (say 10) in your .vsct file - 10 Groups and 10 corresponding Menus, with TextChanges, DynamicVisibility and DefaultInvisible CommandFlags for Menus.

When you need to show a group, you add a corresponding OleMenuCommand and in the BeforeQueryStatus handler set menu command Text and Visible status.

For items you continue to use DynamicItemStart.

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