Select to view content in your preferred language

Hide a Toolbar Item?

640
4
03-06-2012 09:51 AM
GeorgeFaraj
Frequent Contributor
In an ArcEngine application, if I add a command (or tool) to a toolbar can I then hide that command (or tool)?

I can do this:

int itemIndex = toolbar.AddItem("esriControls.ControlsMapFullExtentCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
IToolbarItem item = toolbar.GetItem(elementTool);


But I see nothing in IToolbarItem that sets visibility.  Is this even possible?
0 Kudos
4 Replies
LeoDonahue
Deactivated User
I didn't see the abillity to toggle visibility of a ToolbarItem in the API, other than removing the item from the Toolbar given an item index.
0 Kudos
GeorgeFaraj
Frequent Contributor
I didn't see the abillity to toggle visibility of a ToolbarItem in the API, other than removing the item from the Toolbar given an item index.


Uggggghhhhh! Now I have a chicken and egg problem. (I want to use a command index in a ToolbarMenu before it is created - I figured if I could load it first in the toolbar and then hide it that would solve my problem. So now I need 2 toolbars because 1 doesn't really work.)
0 Kudos
LeoDonahue
Deactivated User
Did you look at ICommandItem?  The delete method just removes the command from the commandbar.  The docs indicate you can add that command back at a later time.
0 Kudos
GeorgeFaraj
Frequent Contributor
Did you look at ICommandItem?  The delete method just removes the command from the commandbar.  The docs indicate you can add that command back at a later time.


That's Desktop stuff - I'm Engine only.

I did find a solution that worked. I instantiate a seperate toolbar and load all my commands into that toolbar in any order I want and then I share that toolbar's CommandPool with the UI toolbar. I can then load the UI toolbar however I want. Sure would be nice if I could just hide an item tho. Can't see why that has never been requested.
0 Kudos