Imports System.Diagnostics
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinToolbars
Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button24.Click
If Me.UltraToolbarsManager1.Tools.Exists("MyContextMenu") = False Then
' ----------------------------------------------------------------------------
' Create a PopupMenuTool.
Dim popupMenuTool As New PopupMenuTool("MyContextMenu")
' Always add new tools to the UltraToolbarManager's root tools collection
' before adding them to menus or toolbars.
Me.UltraToolbarsManager1.Tools.Add(popupMenuTool)
' Set some properties on the Popup menu
PopupMenuTool.Settings.SideStripText = "Infragistics"
PopupMenuTool.Settings.SideStripWidth = 24
PopupMenuTool.Settings.IsSideStripVisible = DefaultableBoolean.True
' ----------------------------------------------------------------------------
' 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")
' Set some properties on the tools.
menuButton1.SharedProps.Caption = "Option 1"
menuButton1.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Warning.Handle)
menuButton2.SharedProps.Caption = "Option 2"
menuButton2.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Application.Handle)
menuButton3.SharedProps.Caption = "Option 3"
menuButton3.SharedProps.AppearancesSmall.Appearance.Image = Bitmap.FromHicon(SystemIcons.Information.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() {menuButton1, menuButton2, menuButton3})
' Add the tools to the popup menu
popupMenuTool.Tools.AddToolRange(New String() {"MenuButton1", "MenuButton2", "MenuButton3"})
' Show and position the popup so that its upper left corner is aligned with
' the lower left corner of the button that generated this click event.
popupMenuTool.ShowPopup(Me.PointToScreen(New Point(Me.Button24.Left, Me.Button24.Bottom)), _
Me.Button24.RectangleToScreen(Me.Button24.ClientRectangle), _
DropDownPosition.BelowExclusionRect)
Else
' Show and position the popup so that its upper left corner is aligned with
' the lower left corner of the button that generated this click event.
Me.UltraToolbarsManager1.ShowPopup("MyContextMenu", Me.PointToScreen(New Point(Me.Button24.Left, Me.Button24.Bottom)))
End If
End Sub