The list items that appear in a ListTool have a value and display a text string. The text and the value of the ListItem are often the same, but they do not have to be. This property specifies the text that will be displayed in the list for this item.
Imports System.Diagnostics Imports Infragistics.Win Imports Infragistics.Win.UltraWinToolbars Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click ' ---------------------------------------------------------------------------- ' Create a PopupMenuTool. Dim fileMenu As New PopupMenuTool("FileMenu") ' Always add new tools to the UltraToolbarManager's root tools collection ' before adding them to menus or toolbars. Me.UltraToolbarsManager1.Tools.Add(fileMenu) ' Set some properties on the Popup menu fileMenu.SharedProps.Caption = "&File" ' ---------------------------------------------------------------------------- ' Create the usual File menu tools. Dim newTool As New ButtonTool("New") Dim openTool As New ButtonTool("Open") Dim closeTool As New ButtonTool("Close") Dim saveTool As New ButtonTool("Save") Dim saveAsTool As New ButtonTool("SaveAs") Dim printTool As New ButtonTool("Print") Dim printPreviewTool As New ButtonTool("PrintPreview") Dim fileMruListTool As New ListTool("FileMRUList") Dim exitTool As New ButtonTool("Exit") ' Set some properties on the tools. newTool.SharedProps.Caption = "&New" newTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Warning.Handle) openTool.SharedProps.Caption = "&Open" openTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Application.Handle) closeTool.SharedProps.Caption = "&Close" closeTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Error.Handle) saveTool.SharedProps.Caption = "&Save" saveTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Information.Handle) saveAsTool.SharedProps.Caption = "Save &As" saveAsTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.WinLogo.Handle) printTool.SharedProps.Caption = "&Print" printTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Hand.Handle) printPreviewTool.SharedProps.Caption = "Print Pre&view" printPreviewTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Question.Handle) fileMruListTool.DisplayCheckmark = False fileMruListTool.MaxItemsToDisplay = 10 fileMruListTool.MoreItemsText = "More files..." ' Add some MRU entries to the List tool. The List tool is a special tool that ' can only be placed on a menu (not on a toolbar). Unlike other tools which ' result in a single menuitem being displayed on a menu, the ListTool will cause ' a menuitem to be displayed for each ListToolItem in the list. Dim mruListItem As ListToolItem mruListItem = fileMruListTool.ListToolItems.Add("file1", "C:\\Temp\\bootlog1.txt") mruListItem.Value = "C:\\Temp\\bootlog1.txt" mruListItem = fileMruListTool.ListToolItems.Add("file2", "C:\\Temp\\bootlog2.txt") mruListItem.Value = "C:\\Temp\\bootlog2.txt" mruListItem = fileMruListTool.ListToolItems.Add("file3", "C:\\Temp\\bootlog3.txt") mruListItem.Value = "C:\\Temp\\bootlog3.txt" mruListItem = fileMruListTool.ListToolItems.Add("file4", "C:\\Temp\\bootlog4.txt") mruListItem.Value = "C:\\Temp\\bootlog4.txt" mruListItem = fileMruListTool.ListToolItems.Add("file5", "C:\\Temp\\bootlog5.txt") mruListItem.Value = "C:\\Temp\\bootlog5.txt" exitTool.SharedProps.Caption = "E&xit" exitTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Warning.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() {newTool, openTool, closeTool, saveTool, saveAsTool, printTool, printPreviewTool, fileMruListTool, exitTool}) ' Add the tools to the popup menu fileMenu.Tools.AddToolRange(New String() {"New", "Open", "Close", "Save", "SaveAs", "Print", "PrintPreview", "FileMRUList", "Exit"}) ' Add some separators between the tools. fileMenu.Tools("Save").InstanceProps.IsFirstInGroup = True fileMenu.Tools("Print").InstanceProps.IsFirstInGroup = True fileMenu.Tools("FileMRUList").InstanceProps.IsFirstInGroup = True fileMenu.Tools("Exit").InstanceProps.IsFirstInGroup = True ' ---------------------------------------------------------------------------- ' Create a main menu bar and add the popup menu to it. Me.UltraToolbarsManager1.Toolbars.AddToolbar("MyMainMenuBar") ' Make the toolbar a main menu bar. Me.UltraToolbarsManager1.Toolbars("MyMainMenuBar").IsMainMenuBar = True Me.UltraToolbarsManager1.Toolbars("MyMainMenuBar").Tools.AddTool("FileMenu") End Sub Private Sub UltraToolbarsManager1_ToolClick(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) Handles UltraToolbarsManager2.ToolClick Select Case (e.Tool.Key) Case "FileMRUList" Debug.WriteLine("The FileMRUList item with a key of '" + e.ListToolItem.Key + "', text of '" + e.ListToolItem.Text + "', Index of '" + e.ListToolItem.Index + "' and Value of '" + e.ListToolItem.Value.ToString() + "' was clicked.") End Select End Sub
using System.Diagnostics; using Infragistics.Win; using Infragistics.Win.UltraWinToolbars; private void button6_Click(object sender, System.EventArgs e) { // ---------------------------------------------------------------------------- // Create a PopupMenuTool. PopupMenuTool fileMenu = new PopupMenuTool("FileMenu"); // Always add new tools to the UltraToolbarManager's root tools collection // before adding them to menus or toolbars. this.ultraToolbarsManager1.Tools.Add(fileMenu); // Set some properties on the Popup menu fileMenu.SharedProps.Caption = "&File"; // ---------------------------------------------------------------------------- // Create the usual File menu tools. ButtonTool newTool = new ButtonTool("New"); ButtonTool openTool = new ButtonTool("Open"); ButtonTool closeTool = new ButtonTool("Close"); ButtonTool saveTool = new ButtonTool("Save"); ButtonTool saveAsTool = new ButtonTool("SaveAs"); ButtonTool printTool = new ButtonTool("Print"); ButtonTool printPreviewTool = new ButtonTool("PrintPreview"); ListTool fileMruListTool = new ListTool("FileMRUList"); ButtonTool exitTool = new ButtonTool("Exit"); // Set some properties on the tools. newTool.SharedProps.Caption = "&New"; newTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Warning.Handle); openTool.SharedProps.Caption = "&Open"; openTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Application.Handle); closeTool.SharedProps.Caption = "&Close"; closeTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Error.Handle); saveTool.SharedProps.Caption = "&Save"; saveTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Information.Handle); saveAsTool.SharedProps.Caption = "Save &As"; saveAsTool.SharedProps.AppearancesSmall.Appearance.Image= Bitmap.FromHicon(SystemIcons.WinLogo.Handle); printTool.SharedProps.Caption = "&Print"; printTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Hand.Handle); printPreviewTool.SharedProps.Caption = "Print Pre&view"; printPreviewTool.SharedProps.AppearancesSmall.Appearance.Image= Bitmap.FromHicon(SystemIcons.Question.Handle); fileMruListTool.DisplayCheckmark = false; fileMruListTool.MaxItemsToDisplay = 10; fileMruListTool.MoreItemsText = "More files..."; // Add some MRU entries to the List tool. The List tool is a special tool that // can only be placed on a menu (not on a toolbar). Unlike other tools which // result in a single menuitem being displayed on a menu, the ListTool will cause // a menuitem to be displayed for each ListToolItem in the list. ListToolItem mruListItem = null; mruListItem = fileMruListTool.ListToolItems.Add("file1", "C:\\Temp\\bootlog1.txt"); mruListItem.Value = "C:\\Temp\\bootlog1.txt"; mruListItem = fileMruListTool.ListToolItems.Add("file2", "C:\\Temp\\bootlog2.txt"); mruListItem.Value = "C:\\Temp\\bootlog2.txt"; mruListItem = fileMruListTool.ListToolItems.Add("file3", "C:\\Temp\\bootlog3.txt"); mruListItem.Value = "C:\\Temp\\bootlog3.txt"; mruListItem = fileMruListTool.ListToolItems.Add("file4", "C:\\Temp\\bootlog4.txt"); mruListItem.Value = "C:\\Temp\\bootlog4.txt"; mruListItem = fileMruListTool.ListToolItems.Add("file5", "C:\\Temp\\bootlog5.txt"); mruListItem.Value = "C:\\Temp\\bootlog5.txt"; exitTool.SharedProps.Caption = "E&xit"; exitTool.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Warning.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 [] {newTool, openTool, closeTool, saveTool, saveAsTool, printTool, printPreviewTool, fileMruListTool, exitTool} ); // Add the tools to the popup menu fileMenu.Tools.AddToolRange(new string [] {"New", "Open", "Close", "Save", "SaveAs", "Print", "PrintPreview", "FileMRUList", "Exit"} ); // Add some separators between the tools. fileMenu.Tools["Save"].InstanceProps.IsFirstInGroup = true; fileMenu.Tools["Print"].InstanceProps.IsFirstInGroup = true; fileMenu.Tools["FileMRUList"].InstanceProps.IsFirstInGroup = true; fileMenu.Tools["Exit"].InstanceProps.IsFirstInGroup = true; // ---------------------------------------------------------------------------- // Create a main menu bar and add the popup menu to it. this.ultraToolbarsManager1.Toolbars.AddToolbar("MyMainMenuBar"); // Make the toolbar a main menu bar. this.ultraToolbarsManager1.Toolbars["MyMainMenuBar"].IsMainMenuBar = true; this.ultraToolbarsManager1.Toolbars["MyMainMenuBar"].Tools.AddTool("FileMenu"); } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "FileMRUList": Debug.WriteLine("The FileMRUList item with a key of '" + e.ListToolItem.Key + "', text of '" + e.ListToolItem.Text + "', Index of '" + e.ListToolItem.Index + "' and Value of '" + e.ListToolItem.Value.ToString() + "' was clicked."); break; } }
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