Toolbar control


In this topic


About the Toolbar control

A toolbar is a collection of tools and commands, divided into categories that perform similar types of actions. When building a Web application, you drag and drop a toolbar onto a form, then select the tools, commands, spaces, and separators you want to add.
You can add standard and custom tools to a toolbar. The standard tools are included with the Web Application Developer Framework (ADF) and consist of common map navigation tasks, such as pan and zoom. Standard tools do not require any coding and can be added to the map by clicking.
Toolbars can also include tools that you develop using the Web ADF or other libraries. Organize the code for a custom tool or command in a class library that you create as a separate project in Visual Studio. When you have written the code for the tool, add the project to your Web application to make use of its functionality. You can then set the tool's specific properties—such as, its icon and client-side action—within the ToolbarItems' Collection Editor dialog box.
For information on customization and configuration of tools, commands, or drop-down items, see Creating and configuring custom tools, commands, and drop-down items.

Using the control

  1. To use the Toolbar control, add supporting controls to the page. Set up a Web application with (at a minimum) MapResourceManager and Map controls. Drag and drop MapResourceManager, Map, and Toolbar controls on the Web form. See the following screen shot that shows the controls on the page in Visual Studio:

    Toolbar when first added to page
  2. Set the Toolbar control's BuddyControls and ToolbarItems properties. See the following screen shots:


  3. Specify the Map or PageLayout control the toolbar uses through the Toolbar control's BuddyControls properties. Click the ellipsis button next to the BuddyControls' property value. See the following screen shot that shows the BuddyControls property on the Properties window:

    Toolbar control properties
  4. After you click the ellipsis button in the preceding screen shot, the BuddyControl Collection Editor dialog box appears. On this dialog box, add one or more Map or PageLayout controls that the toolbar uses. A toolbar can only have one type of buddy control, either Map or PageLayout, but not both. Use the BuddyControlType property on the Properties window to specify which type the toolbar works with. 
  5. To add toolbar items, click the Toolbar control. On the Properties window, click the ellipsis button next to the ToolbarItems property. The ToolbarCollectionEditorForm appears with a list of available toolbar items and current toolbar contents.
  6. In the Toolbar Items column, select an item to add. The Web ADF includes a set of common map navigation tools and commands. These tools and commands have preconfigured client and server actions, and are grouped under the Map Navigation category. Select the whole category or expand the category and select individual items. If you have written code for a custom tool or command, select the empty area next to the word "Tool" or "Command," respectively.
  7. Click Add. The ToolbarCollectionEditorForm dialog box shows the added tools and also the expanded properties for the tools. See the following screen shot that shows the ToolbarCollectionEditorForm dialog box:


Toolbar control items

A Toolbar control can contain multiple ToolbarItem objects. A ToolbarItem can be one of the following types:
  • Tool—Requires interaction from an end-user before executing. Tools have a client action and a server action. For example, to use a Zoom In tool, you interact with a Map control by dragging a box over it. Client-side JavaScript draws the box on the screen, then the server action executes when the map zooms in to the specified extents.
  • Command—Executes immediately when clicked; therefore, it requires no end-user interaction. For example, when you click a full extent command, you do not have to interact with the map (it zooms immediately to the full extent). A command can have a client action, a server action, or both.
  • DropDownBox—Allows interaction with a control by selecting an item from a list, such as layers, data frames, or extent bookmarks, and performs an action based on that selection. Set the items in the DropDownBox from the ToolbarCollectionEditorForm dialog box or set the items programmatically.
  • Separator—Line between items on the Toolbar control that allows you to create groups of related items on the toolbar. For example, you can place a separator on the toolbar to distinguish your geoprocessing tools from your terrain analysis tools. Alternatively, you can create a separate toolbar for each category.
  • Space—Allows you to make room on your Toolbar control for other Hypertext Markup Language (HTML) controls or Web controls. Use the Size property for a Space object to specify the size you want on your toolbar. A size of 1 equals a space of 10 pixels; however, a space can vary with the size of a Toolbar control. If you shrink a Toolbar control, the space size decreases before other items are truncated. A Space object does not execute any action.

Members

The following table shows a list of properties related to the Toolbar control. For more reference information, see the Toolbar control in the library reference section.
Property name
Type
Description
Alignment
Alignment
Alignment of text and images on a command or tool.
BuddyControls
BuddyControlCollection
Set of PageLayout or Map controls that the Toolbar control uses.
BuddyControlType
BuddyControlType
Type of buddy controls associated with this control. A set of Map controls or PageLayout controls can be associated with this control, but not both sets.
CurrentTool
string
Selected tool on the toolbar. There can only be one CurrentTool among a group of Toolbar controls.
Group
string
Group to which the toolbar belongs. A group of Toolbar controls can have only one CurrentTool. The Group property cannot be set to null or to an empty string.
Orientation
Orientation
Horizontal or vertical orientation of the toolbar.
TextPosition
TextPosition
Position of the text with reference to the image on a command or tool. Applies only to toolbars with the ImageAndText ToolbarStyle.
ToolbarItemDefaultStyle
Style
Style applied to commands and tools when they are not selected, disabled, or hovered over.
ToolbarItemDisabledStyle
Style
Style applied to commands and tools when they are disabled.
ToolbarItemHoverStyle
Style
Style applied to commands and tools when they are hovered over.
ToolbarItems
ToolbarItemCollection
Collection of ToolbarItem objects on the toolbar. Defined tools override the ToolItems on the Map or PageLayout controls set up as the Toolbar's buddy controls.
ToolbarItemSelectedStyle
Style
Style applied to commands and tools when selected.
ToolbarStyle
ToolbarStyle
Style of the toolbar. Determines if the toolbar shows text and images for a command or tool, or only text or images.

Events

The following table shows a list of events related to the Toolbar control. For more reference information, see the Toolbar control in the library reference section.
Event type
Description
CommandClick
Raised when a command on the toolbar is clicked. A viable option for handling all commands in one location.
DropDownBoxIndexChange
Raised when the selected index of a select item on the toolbar changes. Only fired if AutoPostBack is set to true on the select item.


See Also:

Creating and configuring custom tools, commands, and drop-down items
Web ADF controls