Version

AddToolbar Method

Adds a UltraToolbar object to the ToolbarsCollection and assigns the specified key.
Syntax
'Declaration
 
Public Function AddToolbar( _
   ByVal key As String _
) As UltraToolbar
public UltraToolbar AddToolbar( 
   string key
)

Parameters

key
A unique key to identify the toolbar in the collection.
Example
The following code demonstrates how to create a a popup menu that sits on a toolbar. It popuplates the menu with a number of tools including another popup menu tool.

Imports System.Diagnostics
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinToolbars

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

		' ----------------------------------------------------------------------------
		' Create a PopupMenuTool.
		Dim popupMenuTool1 As New PopupMenuTool("PopupMenu1")

		' Always add new tools to the UltraToolbarManager's root tools collection
		' before adding them to menus or toolbars.
		Me.UltraToolbarsManager1.Tools.Add(popupMenuTool1)


		' Set some properties on the Popup menu
		popupMenuTool1.AllowTearaway = True
		popupMenuTool1.SharedProps.Caption = "Popup Menu 1"


		' ----------------------------------------------------------------------------
		' Create a some tools and add them to the menu .
		Dim menuButton1 As New ButtonTool("MenuButton1")
		Dim menuButton2 As New ButtonTool("MenuButton2")
		Dim menuButton3 As New ButtonTool("MenuButton3")
		Dim mdiWindowListTool As New MdiWindowListTool("WindowList")


		' Set some properties on the tools.
		menuButton1.SharedProps.Caption = "Button1"
		menuButton1.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Warning.Handle)
		menuButton2.SharedProps.Caption = "Button2"
		menuButton2.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Application.Handle)
		menuButton3.SharedProps.Caption = "Button3"
		menuButton3.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Information.Handle)


		' Specify which window list commands to show.
		mdiWindowListTool.DisplayArrangeIconsCommand = MdiWindowListCommandDisplayStyle.Hide
		mdiWindowListTool.DisplayCascadeCommand = MdiWindowListCommandDisplayStyle.DisplayOnMenu
		mdiWindowListTool.DisplayCloseWindowsCommand = MdiWindowListCommandDisplayStyle.DisplayOnMenuAndDialog
		mdiWindowListTool.DisplayMinimizeCommand = MdiWindowListCommandDisplayStyle.DisplayOnMenuAndDialog
		mdiWindowListTool.DisplayTileHorizontalCommand = MdiWindowListCommandDisplayStyle.DisplayOnDialog
		mdiWindowListTool.DisplayTileVerticalCommand = MdiWindowListCommandDisplayStyle.Hide


		' Always add new tools to the UltraToolbarManager's root tools collection
		' before adding them to menus or toolbars.
		Me.UltraToolbarsManager1.Tools.AddRange(New ToolBase() {menuButton1, menuButton2, menuButton3, mdiWindowListTool})

		' Add the tools to the popup menu
		popupMenuTool1.Tools.AddToolRange(New String() {"MenuButton1", "MenuButton2", "MenuButton3", "WindowList"})


		' ----------------------------------------------------------------------------
		' Create a toolbar and add the popup menu to it.
		Me.UltraToolbarsManager1.Toolbars.AddToolbar("MyPopupMenuToolbar")
		Me.UltraToolbarsManager1.Toolbars("MyPopupMenuToolbar").Tools.AddTool("PopupMenu1")


		' ----------------------------------------------------------------------------
		' Create a second PopupMenuTool and add it to the first.  This second menu will
		' 'cascade out' from the first menu when clicked.
		Dim popupMenuTool2 As New PopupMenuTool("PopupMenu2")

		' Always add new tools to the UltraToolbarManager's root tools collection
		' before adding them to menus or toolbars.
		Me.UltraToolbarsManager1.Tools.Add(popupMenuTool2)


		' Set some properties on the Popup menu
		popupMenuTool2.AllowTearaway = True
		popupMenuTool2.SharedProps.Caption = "Popup Menu 2"

		' Create a some tools and add them to the second menu .
		Dim menuButton4 As New ButtonTool("MenuButton4")
		Dim menuButton5 As New ButtonTool("MenuButton5")
		Dim menuButton6 As New ButtonTool("MenuButton6")

		' Set some properties on the tools.
		menuButton4.SharedProps.Caption = "Button4"
		menuButton4.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Hand.Handle)
		menuButton5.SharedProps.Caption = "Button5"
		menuButton5.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Question.Handle)
		menuButton6.SharedProps.Caption = "Button6"
		menuButton6.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.WinLogo.Handle)

		' Always add new tools to the UltraToolbarManager's root tools collection
		' before adding them to menus or toolbars.
		Me.UltraToolbarsManager1.Tools.AddRange(New ToolBase() {menuButton4, menuButton5, menuButton6})

		' Add the tools to the second popup menu
		popupMenuTool2.Tools.AddToolRange(New String() {"MenuButton4", "MenuButton5", "MenuButton6"})

		' Add the second popup menu to the first popup menu.
		popupMenuTool1.Tools.AddTool("PopupMenu2")

	End Sub
using System.Diagnostics;
using Infragistics.Win;
using Infragistics.Win.UltraWinToolbars;

		private void button3_Click(object sender, System.EventArgs e)
		{

			// ----------------------------------------------------------------------------
			// Create a PopupMenuTool.
			PopupMenuTool popupMenuTool1	= new PopupMenuTool("PopupMenu1");

				// Always add new tools to the UltraToolbarManager's root tools collection
				// before adding them to menus or toolbars.
				this.ultraToolbarsManager1.Tools.Add(popupMenuTool1);


				// Set some properties on the Popup menu
				popupMenuTool1.AllowTearaway		= true;
				popupMenuTool1.SharedProps.Caption	= "Popup Menu 1";


			// ----------------------------------------------------------------------------
			// Create a some tools and add them to the menu .
			ButtonTool			menuButton1			= new ButtonTool("MenuButton1");
			ButtonTool			menuButton2			= new ButtonTool("MenuButton2");
			ButtonTool			menuButton3			= new ButtonTool("MenuButton3");
			MdiWindowListTool	mdiWindowListTool	= new MdiWindowListTool("WindowList");

				// Set some properties on the tools.
				menuButton1.SharedProps.Caption	= "Button1";
				menuButton1.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Warning.Handle);
				menuButton2.SharedProps.Caption	= "Button2";
				menuButton2.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Application.Handle);
				menuButton3.SharedProps.Caption	= "Button3";
				menuButton3.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Information.Handle);


				// Specify which window list commands to show.
				mdiWindowListTool.DisplayArrangeIconsCommand	= MdiWindowListCommandDisplayStyle.Hide;
				mdiWindowListTool.DisplayCascadeCommand	= MdiWindowListCommandDisplayStyle.DisplayOnMenu;
				mdiWindowListTool.DisplayCloseWindowsCommand	= MdiWindowListCommandDisplayStyle.DisplayOnMenuAndDialog;
				mdiWindowListTool.DisplayMinimizeCommand	= MdiWindowListCommandDisplayStyle.DisplayOnMenuAndDialog;
				mdiWindowListTool.DisplayTileHorizontalCommand= MdiWindowListCommandDisplayStyle.DisplayOnDialog;
				mdiWindowListTool.DisplayTileVerticalCommand	= MdiWindowListCommandDisplayStyle.Hide;


				// Always add new tools to the UltraToolbarManager's root tools collection
				// before adding them to menus or toolbars.
				this.ultraToolbarsManager1.Tools.AddRange(new ToolBase [] {menuButton1, menuButton2, menuButton3, mdiWindowListTool} );

				// Add the tools to the popup menu
				popupMenuTool1.Tools.AddToolRange(new string [] {"MenuButton1", "MenuButton2", "MenuButton3", "WindowList"} );


			// ----------------------------------------------------------------------------
			// Create a toolbar and add the popup menu to it.
			this.ultraToolbarsManager1.Toolbars.AddToolbar("MyPopupMenuToolbar");
			this.ultraToolbarsManager1.Toolbars["MyPopupMenuToolbar"].Tools.AddTool("PopupMenu1");


			// ----------------------------------------------------------------------------
			// Create a second PopupMenuTool and add it to the first.  This second menu will
			// 'cascade out' from the first menu when clicked.
			PopupMenuTool popupMenuTool2	= new PopupMenuTool("PopupMenu2");

				// Always add new tools to the UltraToolbarManager's root tools collection
				// before adding them to menus or toolbars.
				this.ultraToolbarsManager1.Tools.Add(popupMenuTool2);


				// Set some properties on the Popup menu
				popupMenuTool2.AllowTearaway		= true;
				popupMenuTool2.SharedProps.Caption	= "Popup Menu 2";

				// Create a some tools and add them to the second menu .
				ButtonTool menuButton4 = new ButtonTool("MenuButton4");
				ButtonTool menuButton5 = new ButtonTool("MenuButton5");
				ButtonTool menuButton6 = new ButtonTool("MenuButton6");

				// Set some properties on the tools.
				menuButton4.SharedProps.Caption	= "Button4";
				menuButton4.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Hand.Handle);
				menuButton5.SharedProps.Caption	= "Button5";
				menuButton5.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Question.Handle);
				menuButton6.SharedProps.Caption	= "Button6";
				menuButton6.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.WinLogo.Handle);

				// Always add new tools to the UltraToolbarManager's root tools collection
				// before adding them to menus or toolbars.
				this.ultraToolbarsManager1.Tools.AddRange(new ToolBase [] {menuButton4, menuButton5, menuButton6} );

				// Add the tools to the second popup menu
				popupMenuTool2.Tools.AddToolRange(new string [] {"MenuButton4", "MenuButton5", "MenuButton6"} );

				// Add the second popup menu to the first popup menu.
				popupMenuTool1.Tools.AddTool("PopupMenu2");

		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also