ICommandSubType Menu Items

675
1
04-11-2012 08:39 AM
GeorgeFaraj
Occasional Contributor III
I'm using a context menu on my map in my ArcEngine application. To create the menu items I've create a class inheriting from BaseCommand and implementing ICommandSubType called "MapContextCommands."  When I populate the ToolbarMenuClass I use the following code for each menu item:

mapContext.AddItem( new MapContextCommands(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly );
mapContext.AddItem( new MapContextCommands(), 2, 0, false, esriCommandStyles.esriCommandStyleTextOnly );
and so on....


What I'm wonder is whether I have to create the class every time.  Would this work?

MapContextCommands mapContextCommands = new MapContextCommands();

mapContext.AddItem( mapContextCommands, 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly );
mapContext.AddItem( mapContextCommands, 2, 0, false, esriCommandStyles.esriCommandStyleTextOnly );
0 Kudos
1 Reply
GeorgeFaraj
Occasional Contributor III
Ignore please.

Answered my own questions.
0 Kudos