Creating tool palettes


Summary Tool palettes provide a compact way to group related tools. Looking somewhat like a menu, tool palettes present either a palette or a menu of tools for users to select from. Unlike menus, however, when a tool is selected from the palette, it assumes the top spot at the toolbar level so you can see it is the active tool.

Tool palettes are new at ArcGIS 10. You no longer have to implement a ToolControl to create one. This topic describes how to implement a custom tool palette by using an add-in and by extending ArcObjects.

In this topic


Using add-ins

Creating an add-in is the easiest and recommended way to implement a custom tool palette. For more information on using add-ins, see Building add-ins for ArcGIS Desktop.

Extending ArcObjects

You can also use the classic Component Object Model (COM) extensibility model to implement a custom tool palette. In this case, create a COM command and implement IToolPalette. You can create a command by implementing ICommand or by having your class inherit from BaseCommand. For more information, see Creating commands and tools.
When implementing IToolPalette, you must specify the tools you want to appear and whether they will be listed menu or palette style. With palette style, you must specify the number of columns; the number of rows is automatically determined at run time to satisfy the count. The following screen shot shows a menu style tool palette:
The following screen shot shows the same tool palette in palette style, with menu style set to false:
The following code excerpt shows an example implementation:
[C#]
#region IToolPalette Members
public bool MenuStyle
{
    get
    {
        return false;
    }
}

public int PaletteColumns
{
    get
    {
        return 2;
    }
}

public int PaletteItemCount
{
    get
    {
        return 5;
    }
}

public bool TearOff
{
    get
    {
        return false;
    }
}

public string get_PaletteItem(int pos)
{
    switch (pos)
    {
        case 0:
            return "esriArcMapUI.SelectFeaturesTool";
        case 1:
            return "esriArcMapUI.SelectByPolygonTool";
        case 2:
            return "esriArcMapUI.SelectByLassoTool";
        case 3:
            return "esriArcMapUI.SelectByCircleTool";
        case 4:
            return "esriArcMapUI.SelectByLineTool";
    }
    return "";
}

#endregion
[VB.NET]
#Region "IToolPalette Members"
Public ReadOnly Property MenuStyle() As Boolean
Get
Return False
End Get
End Property

Public ReadOnly Property PaletteColumns() As Integer
Get
Return 2
End Get
End Property

Public ReadOnly Property PaletteItemCount() As Integer
Get
Return 5
End Get
End Property

Public ReadOnly Property TearOff() As Boolean
Get
Return False
End Get
End Property


Public Function get_PaletteItem(ByVal pos As Integer) As String
    Select Case pos
        Case 0
            Return "esriArcMapUI.SelectFeaturesTool"
        Case 1
            Return "esriArcMapUI.SelectByPolygonTool"
        Case 2
            Return "esriArcMapUI.SelectByLassoTool"
        Case 3
            Return "esriArcMapUI.SelectByCircleTool"
        Case 4
            Return "esriArcMapUI.SelectByLineTool"
    End Select
    Return ""
End Function

#End Region


See Also:

Sample: Create a custom selection extension by extending ArcObjects