Version

ContextMenuInitializing Event

Occurs before a context menu is displayed.
Syntax
'Declaration
 
Public Event ContextMenuInitializing As ContextMenuInitializingEventHandler
public event ContextMenuInitializingEventHandler ContextMenuInitializing
Event Data

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

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
ClickArea Returns an enumeration that describes the area of the control that was right-clicked.
ContextMenu Returns/sets the context menu to be displayed.
Group Returns the UltraExplorerBarGroup for which the context menu is being displayed, or null if the context menu does not relate to a group.
Item Returns the UltraExplorerBarItem for which the context menu is being displayed, or null if the context menu does not relate to an item.
Remarks

This event can be used to either suppress or modify the context menu displayed by the UltraExplorerBar.

Note: When the control's Style property is set to 'OutlookNavigationPane', the ContextMenuInitializing event does not fire for all elements that are right-clicked; in these circumstances, the NavigationContextMenuInitializing event is fired instead.

Example
The following code shows how to process the ContextMenuInitiailizing event.

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.IGControls
Imports Infragistics.Win.UltraWinExplorerBar


	Private Sub ultraExplorerBar1_ContextMenuInitializing(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinExplorerBar.CancelableContextMenuInitializingEventArgs) Handles ultraExplorerBar1.ContextMenuInitializing

		' Add a menuitem of our own to the context menu if the group header was clicked.
		If (e.ClickArea = ClickArea.GroupHeader) Then
			' Reset the group header context menu to remove any menuitems we may have added previously.
			Me.ultraExplorerBar1.ResetGroupHeaderContextMenu()

			Dim myMenuitem As IGMenuItem = New IGMenuItem("Manage Group", New EventHandler(AddressOf Me.OnMenuItemClicked))

			e.ContextMenu.MenuItems.Add(myMenuitem)
		End If

	End Sub

	Private Sub OnMenuItemClicked(ByVal sender As Object, ByVal e As EventArgs)

		' Do something to respond to the click of the menuitem we added.

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


		private void ultraExplorerBar1_ContextMenuInitializing(object sender, Infragistics.Win.UltraWinExplorerBar.CancelableContextMenuInitializingEventArgs e)
		{
			// Add a menuitem of our own to the context menu if the group header was clicked.
			if (e.ClickArea == ClickArea.GroupHeader)
			{
				// Reset the group header context menu to remove any menuitems we may have added previously.
				this.ultraExplorerBar1.ResetGroupHeaderContextMenu();

				IGMenuItem myMenuitem = new IGMenuItem("Manage Group", new EventHandler(this.OnMenuItemClicked));

				e.ContextMenu.MenuItems.Add(myMenuitem);
			}
		}

		internal void OnMenuItemClicked(object sender, EventArgs e)
		{
			// Do something to respond to the click of the menuitem we added.
		}
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