ccposton

ICommandSubType Menu Items

Discussion created by ccposton on Apr 11, 2012
Latest reply on Apr 11, 2012 by ccposton
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 );

Outcomes