Version

NavigationContextMenuInitializing Event

Occurs before a Navigation context menu is displayed.
Syntax
'Declaration
 
Public Event NavigationContextMenuInitializing As NavigationContextMenuInitializingEventHandler
public event NavigationContextMenuInitializingEventHandler NavigationContextMenuInitializing
Event Data

The event handler receives an argument of type CancelableNavigationContextMenuInitializingEventArgs containing data related to this event. The following CancelableNavigationContextMenuInitializingEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
ClickArea Returns the NavigationPaneClickArea constant which describes the area of the navigation pane that was right-clicked by the end user.
Group Returns the UltraExplorerBarGroup for which the context menu is being displayed.
NavigationContextMenu Returns/sets the context menu to be displayed.
Remarks

Note: The NavigationContextMenuInitializing event is fired when an element that is specific to the 'OutlookNavigationPane' setting (of the control's Style property) is right-clicked by the end user. As with the ClickArea property of the CancelableContextMenuInitializingEventArgs class, the ClickArea property describes the area of the navigation pane that was right-clicked.

The ContextMenuInitializing event fires under the 'OutlookNavigationPane' style setting, when the clicked element is not specific to the navigation pane functionality; for example, when an UltraExplorerBarItem is right-clicked. In this case, the NavigationContextMenuInitializing event is not fired.

Example
The following code shows how to process the NavigationContextMenuInitializing event including how to add custom menuitems to the context menu and how to find and disable stock items on the menu.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports System.Diagnostics
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinExplorerBar


	Dim WithEvents myMenuItem As Infragistics.Win.IGControls.IGMenuItem

	Private Sub UltraExplorerBar1_NavigationContextMenuInitializing(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinExplorerBar.CancelableNavigationContextMenuInitializingEventArgs) Handles UltraExplorerBar1.NavigationContextMenuInitializing

		' Reset the NavigationContextMenu so that any changes we made to it during prior firings of the
		' NavigationContextMenuInitializing event will be undone and the 'stock' version of it will be displayed.
		Dim resetContextMenu As ContextMenu = e.ResetMenu()


		' Add a custom menuitem to the NavigationContextMenu.  Create an Infragistics.Win.IGControls.IGMenuItem instead
		' of a Standard Windows Forms MenuItem so that the menuitem is drawn in the correct visual style (Office2003, 
		' Office2000 etc.)
		Me.myMenuItem = New Infragistics.Win.IGControls.IGMenuItem("My MenuItem")
		resetContextMenu.MenuItems.Add(myMenuItem)


		' Disable the 'Open In New Window' stock menu item.  The ContextMenuItemType enumeration will allow us to
		' identify this by comparing the menuitem type of each menuitem against the OpenInNewWindow value if the
		' ContextMenuItemType enumeration.
		Dim menuItem As MenuItem

		For Each menuItem In resetContextMenu.MenuItems
			If e.GetMenuItemType(menuItem) = Infragistics.Win.UltraWinExplorerBar.ContextMenuItemType.OpenInNewWindow Then
				menuItem.Enabled = False
				Exit For
			End If
		Next


		' To ensure that context menu we just reset and modified is the one that gets displayed, assign it to the
		' NavigationContextMenu property of the event args.
		e.NavigationContextMenu = resetContextMenu

	End Sub

	Private Sub MyCustomMenuItemClick(ByVal sender As Object, ByVal e As EventArgs) Handles myMenuItem.Click

		' Perform custom menuitem click processing here.

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


		private void ultraExplorerBar1_NavigationContextMenuInitializing(object sender, Infragistics.Win.UltraWinExplorerBar.CancelableNavigationContextMenuInitializingEventArgs e)
		{
			// Reset the NavigationContextMenu so that any changes we made to it during prior firings of the
			// NavigationContextMenuInitializing event will be undone and the 'stock' version of it will be displayed.
			ContextMenu resetContextMenu = e.ResetMenu();


			// Add a custom menuitem to the NavigationContextMenu.  Create an Infragistics.Win.IGControls.IGMenuItem instead
			// of a Standard Windows Forms MenuItem so that the menuitem is drawn in the correct visual style (Office2003, 
			// Office2000 etc.)
			Infragistics.Win.IGControls.IGMenuItem myMenuItem = new Infragistics.Win.IGControls.IGMenuItem("My MenuItem");

			myMenuItem.Click += new EventHandler(this.MyCustomMenuItemClick);
			resetContextMenu.MenuItems.Add(myMenuItem);


			// Disable the 'Open In New Window' stock menu item.  The ContextMenuItemType enumeration will allow us to
			// identify this by comparing the menuitem type of each menuitem against the OpenInNewWindow value if the
			// ContextMenuItemType enumeration.
			foreach(MenuItem menuitem in resetContextMenu.MenuItems)
			{
				if (e.GetMenuItemType(menuitem) == Infragistics.Win.UltraWinExplorerBar.ContextMenuItemType.OpenInNewWindow)
				{
					menuitem.Enabled = false;
					break;
				}
			}


			// To ensure that context menu we just reset and modified is the one that gets displayed, assign it to the
			// NavigationContextMenu property of the event args.
			e.NavigationContextMenu = resetContextMenu;
		}

		private void MyCustomMenuItemClick(object sender, EventArgs e)
		{
			// Perform custom menuitem click processing here.
		}
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