Select to view content in your preferred language

How to show Caption as well as icon for a Base Command

1132
7
11-17-2010 05:56 PM
RobertDriessen
Deactivated User
Hi

Have no problems creating custom toolbars and commands using visual studio and c#.  Just wanted to know if it was possible to setup a command so that it shows the caption as well as the icon when the toolbar is first used.
This would be the equivilent of right clicking on the button in customise mode and selecting "image and text"

If its possible then please tell me how.

Any help appreciated.

Rob
0 Kudos
7 Replies
vincentLahaye
Emerging Contributor
Hi,

ICommandItem.Style will give you the information for arcmap desktop.
IToolbarItem.Style will give you the information for ArcEngine.

I think you just need to define Style property when you create your toolbar

Vincent
0 Kudos
RobertDriessen
Deactivated User
Hi,

ICommandItem.Style will give you the information for arcmap desktop.
IToolbarItem.Style will give you the information for ArcEngine.

I think you just need to define Style property when you create your toolbar

Vincent


Thank you Vincent

Thats helpful,  but I am having trouble trying to figure out how to get to ICommandItem.  I am using the autogenerated code in Visual Studio for BaseCommand and BaseToolBar
0 Kudos
AlexanderGray
Honored Contributor
ICommandbar.add returns an ICommandItem.  When you add the commands to the toolbar, set the objects returning to an ICommandItem variable.  You can then change the properties.
0 Kudos
PaulBarter
Emerging Contributor
I'm having the same problem understanding where this would be implemented using an ArcMap 10 Add-in.  

I'd like two of my toolbar buttons to default to 'image and text' but the only place I can see the toolbar referenced is in the Config.esriaddinx XML. 

Where should this code be placed so that if fires on startup? 

A VB.Net code snippet would be a bonus. 
Assume I have a toolbar named 'Toolbar1' and a single button named 'Button1'. 

Cheers.
0 Kudos
GaryBroyd
Emerging Contributor
Hi all,

Yes I'd like to know how to do this too as I have followed an example to add a "Base Toolbar" as well as a new "Base Command" (or "Base Tool") item from the "Add New Item" dialog in Visual Studio 2008 and now have a toolbar with a button on it.

But I can't see how to specify the style of the button as the AddItem() method of the BaseToolbar class doesn't return an ICommandItem object.

E.g.

public sealed class My_Toolbar : BaseToolbar
{
 public My_Toolbar()
 {
  //
  // TODO: Define your toolbar here by adding items
  //
  //AddItem("esriArcMapUI.ZoomInTool");
  //BeginGroup(); //Separator
  //AddItem("{FBF8C3FB-0480-11D2-8D21-080009EE4E51}", 1); //undo command
  //AddItem(new Guid("FBF8C3FB-0480-11D2-8D21-080009EE4E51"), 2); //redo command

  //"MyToolbarProj.MyTool" is derived from "BaseTool"
  AddItem("MyToolbarProj.MyTool");
 }
}
0 Kudos
MichaelRobb
Honored Contributor
Thought this thread is a few months old, ill answer anyways.
Hope this helps out Gary. (Im not a C# fan... so its vb here)

I'm having the same problem understanding where this would be implemented using an ArcMap 10 Add-in.  

I'd like two of my toolbar buttons to default to 'image and text' but the only place I can see the toolbar referenced is in the Config.esriaddinx XML. 

Where should this code be placed so that if fires on startup? 

A VB.Net code snippet would be a bonus. 
Assume I have a toolbar named 'Toolbar1' and a single button named 'Button1'. 

Cheers.


I have read other methods such as through the extension if one is created.


Where is the code Fired from?   ENABLED property

Public ReadOnly Property Enabled() As Boolean Implements ICommand.Enabled
SetAsInconAndText()
end Property


And here is the call

        Public Sub SetAsIconAndText()

                ' Make sure button is showing Icon And Text
                Dim pUID As New UID
                pUID.Value = "{F53B91E1-C520-41a7-941C-686AA071D1A2}"  ' Toolbar GUID created!

            Dim pCommandBar As ESRI.ArcGIS.Framework.ICommandBar
            pCommandBar = m_application.Document.CommandBars.Find(pUID, True, False)

            Dim i As Integer
            If Not pCommandBar Is Nothing Then
                For i = 0 To pCommandBar.Count - 1
                    If pCommandBar.Item(i).Name = "Property NAME used for tool" Then ' use the Property NAME of the button
                        pCommandBar.Item(i).Style = esriCommandStyles.esriCommandStyleIconAndText
                        Exit For
                    End If
                Next
            End If


        End Sub
0 Kudos
GaryBroyd
Emerging Contributor
Thought this thread is a few months old, ill answer anyways.
Hope this helps out Gary. (Im not a C# fan... so its vb here)


Thanks for that Mike, I'll give it a go
0 Kudos